żěè¶ĚĘÓƵ

Electronics projects for beginners: Make a robot biscuit butler

Take a BBC micro:bit, add a motor, a chassis and some infrared sensors and then put your feet up with a nice cup of tea: your biscuits will be on their way shortly

[video_player id=”ZBdMibMd” access_level=”everyone”]

New stuff you need

Line sensors

micro:bit edge connector (optional)

YOU have battled batteries, mastered motors and conquered coding. Now, far from the humble reading light you made in week 2, you should be able to build an autonomous line-following robot to bring the biscuits when your hands are full with mugs of tea.

Let’s start with the wheels. Wire your servos to power and ground on the breadboard, and pins 0 and 1 of your micro:bit. Connect ground on the breadboard to ground on the micro:bit, then add the battery pack. You can use the same robot body as last week.

Next, the line sensors. Most have two domed parts that look like LEDs – one emits infrared light, the other detects the reflection. Black reflects less infrared than white, so the sensors know which colour they can see, letting our robot follow a darker line on a lighter background.

Connect the sensors’ “vcc” legs to the micro:bit’s 3v pin and the “gnd” legs to ground (you might need jumper wires with a “socket” end). Link the sensors’ outputs to micro:bit pins 6 and 7, the slivers to the left of pin 1. Like last week, you will need conductive paint or a micro:bit edge connector to do this. Attach the sensors to your biscuit bot’s front so the emitters and receivers point down.

Now, we code. The sensors read 0 when they point at white, so if the biscuit bot’s left sensor reading is 0, it has veered off the line to the left, and if the right sensor reads 0, it has veered right. In each case, the biscuit bot should turn until it is back on the line.

In the code editor, enter the “Loops” menu and grab a “while <true> do” block then snap it into “forever”. Next, take a “0 = 0” comparison from “Logic” and a “digital read pin” block from “Pins”. Make a line that says “while digital read pin p6 = 0″. This handles what the bot should do when it can’t see the line on its left. We want it to turn right. So nestle two “servo write pin” blocks inside your “while”, one to stop the right wheel and another to move the left wheel forward. Underneath, we need a second “while <true> do” block, this time for when the bot can’t see the line on its right. Put “digital read pin p7 = 0″ in the second “while”, then add two more servo blocks inside it with the correct values to turn right.

Download the code and attach the micro:bit’s battery. Finally, draw a thick black line on some white paper with tape or a pen and lay it along your route. If your bot misbehaves, adjust its sensitivity by turning the dials on the sensor boards with a screwdriver.

Congratulations – you have completed our first maker series. I will be back next week with a fresh set of projects focusing on the outdoors. In the meantime, make a cup of tea and put your feet up – the biscuits are on their way.

Thanks to Imperial College Advanced Hackspace for use of their facilities

To download a printable version of this page click here


Starting next week: How to be a maker 2

You have learned the basics – now it’s time to show your skills to the outside world.

From next week, a new 10-part series will focus on making gadgets and gizmos for the great outdoors, from a rain alarm to a tweeting wildlife camera. Stay tuned to make some more!

You will need

BBC micro:bit starter kit

Capacitive soil moisture sensor

Crocodile clips

Jumper wires

Everything you have already learned

Topics: Electronics / Robots