Buggy Control

Workshop challenge


The challenge we have set for you is to learn how to programme a computer to radio control a robot buggy.



The buggy




The buggy is controlled by a computer (micro:bit).





The buggy has two wheels, each one driven by its own motor.






This makes the buggy very easy to steer.


Power up your micro:bit


Now look at the display on your micro:bit.


Your buggy has not had a run about for ages - It is probably feeling sad.

We are going to give your buggy a run - has that cheered it up?

But you don't know how to program your buggy - is it sad again?

You are going to learn how to program it! - that should cheer it up again.



Does your buggy really have emotions?




Interaction at a distance feels like magic.


Magic might be useful if you’re an elf, wizard or unicorn, but such things only exist in stories.


However, there is something much better than magic: science!


Remote control

Driver-less aircraft, boats and vehicles can be controlled remotely without wires through the use of radio waves.

Avoiding interference


If two or more micro:bits are transmitting data there is a chance that they will interfere with each other. 


One vehicle might be receiving data intended for another vehicle. 


To prevent this you must use your own radio group number which we will give you.


 Keep it secret or someone may hack into your buggy.

Coding your buggy

In the MakeCode editor, create a new project called Buggy.


The motors on the buggy are connected to a black Kitronik-robotics-board

This board needs special blocks to program it.

These are found in the Extension blocks.

Search extensions for robotics and then look for a picture of the Kitronik-robotics-board.

Click on the picture to load the extensions.





Once you have installed the Robotics blocks, find the Motors blocks.


The left motor is Motor 1  and the right motor is Motor 2.


Motor test code

We will use button A to start the motors going forwards.

We will now add some code to make the buggy turn right.

To turn right, we need to keep Motor 1 ON and turn Motor 2 OFF for just a second.

Then we start Motor 2 again.

Try to create a script by following this algorithm:


Try to work out how to do this without looking at the hint.

Code Hint

Remote Control Buggy

Using a scond micro:bit as a buggy controller it is possible to control your buggy using radio signals.


Remember, if two or more micro:bits are transmitting data there is a chance that they will use the same radio group number and interfere with each other. 


Do NOT use radio group 42!


You will be given your own radio group number

Keep it secret or someone may hack into your buggy.

Controller micro:bit code

The controller is the micro:bit with a battery pack already attached.

Study the code below. 

Then click on the blue, New Project button in the MakeCode editor.

Name the project control.

Create the code. 

You will need to click on the Radio menu to find the radio blocks.

Download this code onto the controller micro:bit






Buggy micro:bitcode

This is the code for the micro:bit in the buggy. 

Study the code below. 

Then click on the blue, New Project button in the MakeCode editor.

Name the project buggy.

Create the code. 


Remove the micro:bit from the buggy and connect it to the download cable.

Download this code to the micro:bit on the buggy.

Disconnect the download cable.

Replace the micro:bit onto your buggy.

Testing

Follow these instructions carefully:

1. Place your buggy on the floor.

2. Turn the motor board on.

3. Make sure your controller micro:bit is on.

4. Finally, turn the battery pack on your buggy on.

5. Experiment with pressing both buttons A and B on the controller micro:bit to go forwards, button A to turn right and button B to turn left.


OUT OF CONTROL!

If your buggy goes out of control, just pick it up and turn the battery pack off.

When you are ready, start again.

Practise steering your buggy until you can keep it under control.

Extension challenges

1     Program your buggy to go faster.

2     Use the touch logo as a button to program your buggy to go in reverse. You will have to have extra code on your controller and on your buggy micro:bits to make this happen.