DIY Educational Micro:bit Robot

722

9

3

Introduction: DIY Educational Micro:bit Robot

About: From research in the field of computer vision, with many exciting subjects such as augmented reality, 3D reconstruction, autonomous robotics and deep learning, I progressively made my way to another passion ...

This instructable will show you how to build a relatively accessible, capable and cheap robot. My goal in designing this robot was to propose something which most people could afford, for them to teach computer science in an engaging way or to learn about it.

Once you get this robot built you can enjoy its variety of sensors and actuators to do basic but also quite advanced things depending on the version you build (I'll provide two versions). With this robot you are giving eyes (180° view !) and legs (with precise movement possible!) to the micro:bit while the micro:bit provides you great features such as the LED matrix, the radio communication, bluetooth communication, accelerometer, compas, but also access to all that stuff with either MicroPython or with a visual programming language similar to scratch (actually also in C++ and javascript but I find those less suitable for education).

I will also work on this instructable so that I can set the readers and makers on track to discover more about mobile robotics, electronics, designing and wood cutting. To do so, I designed everything to be as modular as possible. For instance I won't use any glue to allow to assemble and disassemble freely, making upgrades as well as debugging easier. I'll also make the steps as incremental as I can, so that you can progressively understand what's going on, check that things are working as they should and reach the end with a robot that works.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Gathering the Pieces

For this project the bear minimum you'll need is:

  • 5 mm thick MDF wood and a laser cutter for the skeleton
  • 1x18650 lithium battery, 1x battery shield for the energy and an interruptor
  • 1xMicro:Bit card and 1xMicro:bit extension board for the brain(although both can be replaced easily by an Arduino)
  • 2x28BYJ-5V stepper motors, 2xA4988 stepper motor drivers and 2x development board to mount the drivers for the legs
  • 1x TOF10120 and 1x Mini 9g Servo motor for the eyesSome cables and screws
  • 1x universal wheel, height = 15mm

Among those, only three parts are not standards, therefore here are links to find them: find the extension board I used here (but I'd recommend you to use this one instead for the neat version of the robot. You'll have to change almost nothing to the design and it will make the wiring much simpler with bend female-female headers), the battery shield here, and the universal wheel here.

Ideally you'll also have at your disposition:

  • A multimeter
  • A breadboard
  • A soldering iron

For those as well as the laser cutter, check if you've got any fablab around your place ! Those are great places to meet some inspiring makers !

Step 2: Getting the Legs Ready

Your first mission, if you accept it, will be to make our stepper motor rotate using the micro:bit as a controller ! Why a stepper motor ? I could have gone for DC motor with reducers but I tried them and I find it hard to get cheap motors to run at low speed. I also thought that it would be nice to know precisely at what speed my wheels are turning. For those reasons stepper motors were the best option.

So now, how to control a 28BYJ motor using a 4988 driver ? The answer is... a bit long. I did not manage to make it fit neatly in this instructable, so I made another one just for this purpose that you'll find here. I invite you to follow those steps until the end with the creation of a little prototyping board 26x22mm big with 2x2mm holes 17 mm appart to mount it on the sides as shown in the picture above (Note that as stated in the referenced article the yellow wire on the left sticking out is just there to remind you to solder SLP and RST together).

After getting this working with one motor with the prototyping board, I also designed my own PCB to make things a bit more tidy. I attached the corresponding easyEDA file. It is a txt file but you can still open it with the easyEDA free online editing platform.

Step 3: I See the Light !! (Optional)

If you just want to build and nothing more, jump to the one before last paragraph of this step to see how to connect a TOF10120 to the micro:bit. If not follow through.

As our micro:bit does not come with any camera or proximity sensor, it makes it sort of blind for any mobile robotics application. It comes with a radio emitter and receptor though which would allow us to build the skeleton over what we already have and get a remote controlled robot. But wouldn't it be great to make our robot autonomous ? Yes it would be ! So let's see how to get there.

What we are interested in now is to equip our robot with sensors, for our robot to acquire some information about its environment. There are many types of sensors available, but here we'll focus on proximity sensor. When I was designing this robot, my goal was mostly that the robot does not crash into anything, therefore I wanted it to sense obstacles. For this there are also a few options. A first, very simple one, could be to use bumpers, but I find the information about the environment a bit limited. On the other extreme, you could think of adding a camera (or a Lidar or a kinect !). I love cameras, computer vision and all those things, but unfortunately Micro:bit does not support those (we'd have to use a raspberry Pi to support such devices, not a micro:bit or Arduino).

So what does micro:bit support that is in between a camera and bumpers ? There are small active sensors that send light to the environment and check what is received to get some information about the world. The one I already knew of was the GP2Y0A41SK0F which uses a triangulation method to estimate the distance to obstacles. However I wondered if I could find anything better, so I did some research and I ended up discovering the TOF10120 (and the GY-VL53L0XV2 but I did not receive it yet :( ). Here is a nice article for you to discover it. Basically this sensor emits an infrared signal that reflects on obstacles and it then receives the reflected light. Depending on the time the light took to go back and forth, the sensor can estimate the distance of the obstacle (hence the name TOF=time of flight). For its small size, distance range and power requirement I decided to use the TOF10120.

While my first idea was to put three of those on the robot (one in front and two on the sides), the Chinese new year and the COVID-19 pandemic did not want it that way as it seemed to cause problems with shipments. So as I was limited to one TOF10120, that I wanted to see on the sides too and that I had some servo motors lying around, I decided to mount my sensor on a servo. So two things are missing now: how do I use the TOF10120 with the micro:bit ? And same question with the servo.

Luckily the micro:bit is equipped with I2C communication protocol and it makes our life really easy: plug the red wire to 3.3V, black to ground, green to SCL and blue to SDA and that's it for the hardware part. For the software, I encourage you to read a bit about I2C communication and try the python code that I attached on the micro:bit. That program should print you the distance measured by the sensor on the REPL (Read Evaluate Print Loop). That's it. We just gave sight to our micro:bit.

Now let's make it turn its neck if you allow me to continue my analogies with animal anatomy. The only think we'll need to that is to drive a servo motor with the micro:bit. This part is getting long so I'll just give you this link which has all the information you'll need and the code I used to test it. If you want I also added a simple code to control the servo using pin0. Just don't forget to power your servo with 5V and not 3.3V.

Step 4: Hacking the Battery Shield

Now that we got our actuators and sensors ready, it's time to have a look at the battery management system. For you to learn more about the battery shield that I chose, I would advise you to read this article. I find it very clear and accessible. From this article we can see many advantages of this battery shield, but there is one important drawback I did not want to accept: the ON/OFF switch does only affect the USB output. This means that if you turn the switch off, all the other 3.3V and 5V pins will be powered. As a result, as we are using those pins for our robot, the switch will do nothing at all...

But I want to be able to turn my robot off not to empty my batterie for nothing, so I had to hack the battery shield. It won't be pretty, but it works and it costs nothing. Therefore I want a switch to open or close the circuit so that it isolates my battery cell from the battery shield. I do not have the equipment to touch the PCB, but I have pieces of plastic all around. So now imagine that I cut a piece of plastic so that it can fit at one end of my battery cell in the shield like in the first image above. The circuit is now open and my battery is safely stored.

Yes but I don't want to have to open the robot to access the battery shield to put and remove this piece of plastic ! Easy: get a switch and tape two little squares of aluminium to each of the wires connected to the switch. Now tape those two pieces of aluminium to the piece of plastic in order to have the two aluminium pieces isolated from each other and in order to have the aluminum exposed to the outside of your system. Normally that should do. Insert your new creation in the battery shield next to the cell, and the switch should allow you to open or close the circuit connected to the cell.

One last thing: to make it easy to assemble and disassemble the robot, I would advise you to solder female headers on the battery shield. This way you can easily plug and unplug what you build with the motors and their drivers.

Step 5: 3D Design and Cut

The only thing missing now is to build the structure that will hold all our components together. To do this I used the online platform tinkercad. This is a really nice environment to do some basic CAD which is often enough for designing things for the laser cutter.

After some time thinking, it was time to tinker. To do so I started to put together 3D models of the different parts I had (first keeping the servo and TOF out of the equation). That includes the battery and shield, the stepper motors and the motor drivers, and of course the micro:bit with its extension board. I attached all the corresponding 3D models as stl files. To ease the process, I decided to make my robot symmetrical. As a result I tinkered with only half of the robot and reached the design shown in the image above.

From this a few versions came to life, from which I selected two:

  • One quite tidy, without the proximity sensor, which allows to have no wires appearing. While not autonomous this version can still be programmed via bluetooth through an iPad for instance, or can be programmed to be controlled using radio signals that can for instance be sent by another micro:bit as shown in the video above.
  • One much less tidy which allows to go much further into mobile robotics as it permits to capture the distance of obstacle with a 180° view thanks to the proximity sensor built on a servo motor.

To build this up, go to your favorite Fablab and use the laser cutter that you find to cut the model of your preference : the first one corresponding to the files design1_5mmMDF.svg and design1_3mmMDF which correspond respectively to the parts to cut in the 5mm MDF wood and the ones to cut from the 3mm one; the second one correspond to the file design2_5mmMDF.svg. Set the black contours to be cut and the red ones to be engraved.

Side note: I added the red pattern just to pimp it up. This is a Hilbert filling function that I generated using the attached python code.

Step 6: Mounting the Beast

The steps I followed to mount the first version of the robot are the following (the pictures should normally be in the right order):

  1. Remove the blue cap of the motors and cut it a bit to make the cable stick out from the back of the motor.
  2. Mount the motors on each side using M2 screws and bolts.
  3. Mount the prototyping board on the sides using the 2x2mm holes and some screws and bolts.
  4. Put the A4988 drivers and tape the motor cables to keep it tidy.
  5. Mount the universal wheel under the bottom part and add the sides.
  6. Mount the extension board of the micro:bit on the top part.
  7. Mount the bottom of the flexible front cover.
  8. Put the batterie shield and connect everything (to do so, as I was still waiting for the delivery of the extension board I wanted and that I only had one with female headers sticking out, I recycled an IDE cable from an old computer to manage to not have my cables sticking up the board in order to cover all this up by the foldable front cover). Although the code I provided is very easy to adapt, to use it directly, you'll need to connect the left STEP to pin 2, right STEP to pin 8, left DIR to pin 12, right DIR to pin 1.
  9. Put the micro:bit in the extension.
  10. Test that everything is working with MoveTest.py before going any further.
  11. Mount the switch on the top part and put the plastic bit next to the lithium cell.
  12. Screw the top part of the front cover.
  13. Mount the back, and you are done ! Phew ! I was not expecting that many steps ! It's so much easier to think about it and do it than to explain it in words ! (And I'm sure there'll still be missing information !)

If you are building the second version with the proximity sensor, then:

  1. Follow the instruction above . The only difference will be that you'll have to add some M2 spacers in step 7 (although that's what I did but it is not required), ignore step 8 and step 13 (as there is no front cover)
  2. Mount the servo motor with M2 screws and connect the VCC and GND of the servo directly on the 5V of the battery shield, and connect the controlling input to pin 0 of the micro:bit.
  3. Mount the two pieces of wood that will go on top of the servo with a screw, screw the TOF sensor on this as well as the white plastic piece that comes with the servo.
  4. Mount this last unit on the servo and connect the sensor using I2C of micro:bit as described in the step 3.

Step 7: Program

That's it ! You've got a robot that you can program either in micro:python or in makecode. I attached here some sample code that I used to do the videos above:

  • Example 1: Put radioControl.py on the micro:bit of the robot and ReadAccelero.py on another micro:bit to control the robot using the inclination of the second micro:bit.
  • Example 2: Put Autonomous.py on the version 2 of the robot it will explore the environment.

Those are just basic examples that you can use to go much, much further. For instance I quite like simultaneous localisation and mapping, and normally there is everything you need in the version 2 of this robot to do that ! Although one big drawback for me to do such a project is that the micro:bit PWM driver is a software driver which uses the same timer for all channels, meaning that all the PWMs we set must have the same frequency (which is something I did not know when I wrote the sample codes although I detected something strange when I wrote Autonomous.py).

Step 8: Going Further

Don't hesitate to improve the design, solve some problems I did not see. For instance I'd like to eventually:

  • Add an IR sensor at the bottom of the robot to make it detect if the ground is black or white or if it is reaching the end of my desk.
  • Change the battery management system as I'm not satisfied with it yet. Indeed, at the moment, to recharge the battery, it requires to disassemble the robot to take the cell or the battery shield out... I'm therefore planing to: 1. add a mini-USB connector on the back of the robot that I'll connect to the battery shield, so that I can recharge it; 2. Cut a hole at the bottom to see the LEDs from the battery shield to see when the charging is over.
  • Check if there is a acceptable way to output PWMs with different frequencies.
  • Try out the VL53L0XV2 to replace the TOF10120 as it could be a cheaper option which would make it accessible to even more people. Although I read more about this sensor and it seems that the company who made this cheap made it on purpose very hard to deal with...
  • Test different designs for the wheels to make them more durable (Right now I'd be expecting that if I take the wheels in and out many times, the wood will progressively be damaged. If I make the wood more elastic modifying the design I might be able to make it last longer)

A big thanks to the people from the Mobile robotics team (now part of the Biorobotics laboratory) of EPFL who helped me a lot expand my knowledge of electronics and mechanics !

Woodworking Contest

This is an entry in the
Woodworking Contest

Be the First to Share

    Recommendations

    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Clocks Contest

      Clocks Contest

    3 Discussions

    0
    NirL
    NirL

    18 days ago

    awesome project!!

    0
    NirL
    NirL

    Reply 18 days ago

    also, why are you not taking a part of a contest??

    0
    amaury_d
    amaury_d

    Reply 18 days ago

    Thank you ! And for your question, well... I didn't take part in any contest because I didn't know about them much. But now that you told me I checked them out and I'll try the woodwork contest ;)