mBot - Conditional and sensoring statement basics

Tools

1 mBot

1 tablet with mBlock app

Step  1 : Connect the mBot to the tablet and go to the programming interface

Use the dedicated button in the upper right-hand corner to connect to the mBot

Step  2 : Try conditional statements

Starting the bot with green led, change the colours of the led accordingly:

  • Change  to red if something comes in front of him (use if block with obstruct ahead block)
  • Change to blue otherwise

Note that the program tests the condition for one time, in case it achieves the red light turns on, otherwise  the program ends

Step  3 : Challenge

Let mBot Move forward if there is anything in front of it the mBot stop and turn red light else turn blue light.