simple line follower
This is a walk through for a simple line follower that can follow a black line on a lighter surface, i used black insulating tape on the floor. The robot can be made in an hour and expanded on easily.
if your pc has a serial port you can buy the cheaper 28 board pack with the serial lead but if like my laptop you haven't you will have to get the one with the usb lead
picaxe 28 board usb
picaxe 28 board serial
picaxe 28x1 chip x1
l293d motor driver x1
resistor 330R x1
resistor 10k x2
The battery box shown hear is not the one one you want, check that they can send you one with 4aa laying next to each other
gm9 with wheels x2
qrb1134ir photorefelctor x2
double sided tape
black insulating tape
4 pin pcb header plug and suitable plug
The 28 board will come with a darlington chip fitted, the robot wont use this chip but you can leave it in to keep it safe. The large chip socket is for the 28x1 chip and the smaller one is for the l293d motor driver, The two chips should not be fitted yet but have to be fitted the right way look for the noches on the chip and chip holder
Next you need to cut a small piece off the strip board, 11 by 6 counting the holes. you will also have to put a break in one of the tracks, have a look at the pic to see where to put it. To make the break use a drill bit and and turn it using your hand.
You need to solder your 2 x 10k resistors and 1 x 330r resistor to the strip board in the places shown above. If your using a 4 pin pcb header plug that should be soldered where the yellow line is, if your not you can solder the ribbon cable straight to the strip board. Next cut down the leads on the two QRB11134IR sensors and solder them to the strip board, there will be a white, blue, green and orange lead they should be soldered where the coloured dots are on the pic above
Your strip board should look something like this i have soldered my leads higher up but there still on the same tracks.
The numbers above the header pins represent the wire on the ribbon cable, you should now solder these to either your plug or on to the strip board
cut 4 bits of wire and soder to the motors and to the 28 board
Fit your wheels to your motors and stick them to the battery box using double sided tape. connect the battery box to the board. Then stick the board to the motors.
Place the 28x1 chip and l293d motor driver chip on the board, make sure you put them on the right way, insulate the strip board with tape and stick it on to the 28x1 chip and connect the ribbon cable. Stick the two sensors to the robot, you want them to be as close to the floor as possible in the centre of the robot, make sure they are just a bit wider than the line you want to follow.
Your robot is now finished and ready to be programed.
install the program that came with your 28 board, put the battery's in your robot connect it to your pc with the lead and open up the program editor.
copy and paste the code below into the editor upload it to your robot, follow the notes in the code (green writing at the bottom in the editor) and make a track and watch it go.
wait 5 'wait 5 seconds to start
readadc 3,b0 'read one sensor
readadc 2,b1 'read the other sensor
if b0>251 and b1<251 then 'check if sensor b0 can see black,
low 4 high 5 low 6 high 7 'these should make your robot turn its b0 sensor away from the black line,
if b0<251 and b1>251 then 'check if sensor b1 can see black
high 4 low 5 high 6 low 7 'these should make your robot turn its b1 sensor away from the black line
else 'if none of the sensors see the black line then move forward
low 4 high 5 high 6 low 7 'these should make your robot move forward
' lines 6, 9, and 11 will need to be changed for you robot to work
' you must change the high,low on motors a and b,
' high 4 low 5 will make motor A go in one direction and low 4 high 5 will make it go the other way, 6 and 7 control motor B
' put the battery in and hold the robot in the air and wait for it to start, both motors should drive forward if they dont change the high low combanation on line 11
' when you have got both motors running forward you can work out how to change lines 6 and 9
' make a circuit for the robot to follow and place the robot on it
' if your robot turns the wrong way when it gets to a turn switch the sensors over, right to left and left to right