Look forward to your further feedback after tried the suggested code.
Besides, you can also try upload the factory firmware (06.01.009) with which you can play the mBot with IR remote controller or switch the three modes by pressing the on board button.
The online firmware (06.01.107) is a firmware for supporting debug online firmware. Usually mBot will not have special performance when the online firmware uploaded successfully.
Here is the difference between online firmware and factory firmware for mBot to you for reference:
a. if you have done the process about “upload to Arduino”, and you want to use the default function such as “object avoid mode”, “line following mode” please choose “factory firmware”;
b. if you want use mBlock to program the boards, “online firmware” could support all function blocks shows on the script pane;
c. The reason of the different between two setting is we could access the memory limited of the arduino chip to put all factory default program and support all function blocks in mBlock.