08.11.2019 Views

micromag-6

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Cover Feature<br />

ROBOTS<br />

Coding the Robot<br />

Parts List:<br />

With Microsoft MakeCode<br />

6. The next function will make the robot turn right 7. The next function will trigger the robot to reverse<br />

8. With the functions created, lets create a short test script that will call<br />

each of the functions in turn, so that we can check that our robot is<br />

working. Inside “on start” we shall use the “call” blocks from Functions<br />

and call each of the functions. We start with “stop”, then forward at<br />

half speed (512) then use a pause from Basic to force the robot to<br />

travel for 2 seconds. And the process carries on with each function<br />

call, and pause until we reach the end and add another stop.<br />

Download the code and copy it to your micro:bit. When it has<br />

finished, remove the micro USB lead and connect the micro:bit to<br />

the 3.3V output of the voltage regulator. Your robot will come to life<br />

and start driving around. Check that it follows the correct sequence,<br />

forward, backward, left, right. If a motor moves in the wrong direction,<br />

unscrew the wires from the motor controller and swap them around.<br />

When you are happy, change the sequence of code so that your robot<br />

draws a square, navigates around the room, delivers you food! This is<br />

your robot, and it will do what you tell it to do!<br />

26<br />

<strong>micromag</strong>.cc

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!