premiers pas

For this lesson you will need:

  • mBot 101 fully assembled
  • Computer running mBlock
  • USB cable to connect the robot to the computer

Before making your program, ensure the connection is establiched between the mBot 101 and your computer.

Configure the connection in mBlock

When you start mBlock you have to check some of the connection parameters.

In the top menu click on Boards and select Me Uno Shield. board select

Then click the Connect menu and look in Serial Port.

serialPort Empty

Info
Depending on your computer Operating system the content of this panel will be different
- on osx you will probably have an empty menu
- on windows you will probably see COMX

Now it's time to plug your robot in you computer usb port and check Serial Port again.

serialPort Found

You should see a new entry in this menu (in this case COM4 ); this is you mBot 101. Click on this entry to start the connection between the robot and the computer.

Create your first program

The mBlock application is based on Scratch2.0 1 from MIT with the addition of the Robot tab , witch is the one where you can interact with the robot.

robotTab

Let's get to work

From the Event tab drag and drop one when [key] key pressed block and two set motor [Port] speed [100] blocks.

fwd key

CAUTION : make sure the port are the good one for you robot.

Now we have created a stack of block that will make the robot move forward as you press the key of your keyboard.

But we are not done yet.

If you try it right now you will face problem to stop the robot (you already did ? aren't you ? no problem). In case of trouble you can click on the STOP icone in the top right corner of the panda's window.

fflag stop btn

So we need to create a stack for when we release the key.

For this we're going to do the same except that we are going to specify the robot to stop when key is release.

try to do it whitout looking right now to the solution.

first move

Info
The value of the speed are opposed in regards of the motor assembly the motor are mirored one the one other so the speed value have to reflec that if you put the same value on both the robot will turn aroun on it self.

Try to put the same value and give it a go.

Well done! You juste programmed your first robot behavior in mBlock

>To go futher
Try now to create all 4 buttons to drive the robot forward, backward, left and right. Don't forget the release statement
View solution
fflag stop btn

Congratulation

You can now play around with mBlock to control your robot in various ways. Try to explore more functionnalities by your self before getting to the next lesson.


  1. visit scratch website, Link ↩︎