Introduction: Arduino Based Line Following Robot
The following Instructible deals with making a simple line following robot using arduino uno.
Please note that I am a beginner. This is my first time working with arduino. I welcome all criticism, comments and advice. :)
This project, I believe can give you a good intro into using arduino micro controller. For a pro, I do not think it will take more than 2 hours, but for a noob like me, it can take a week, learning each aspects one by one.
So, first things first, what do you need to make your line following robot:
1. Arduino Uno (or any other boards)
2. L293D Motor Driver (I believe you can use a shield instead)
3. Robot Chassis with geared motor and castor wheel
4. Two IR proximity sensors
5. Two 9v batteries
Step 1: Step 1
Attach the L293D motor driver to a basic circuit board (or a breaad board). Make the connections show in the attached image. Ports 2, 7, 10 and 15 are the inputs of the arduino. So attach wires to them which can later be connected to the arduino. The 5 volt supply can come from the arduino. It is for operating the IC. The 9 volt supply is for operating the motors. (Actually, it is not neccessary to provide exactly 9 volts. Just provide an apt voltage for the motor)
Step 2: Step 2:
Set up the robot chassis. This tutorial deals with a 2 wheel drive with a third castor wheel. You can find it easily in amazon or any store with easy instructions.
Step 3: Step 3:
Attach the IR proximity sensors to the front of the chassis. Make sure that there is atleast 2 cm gap in between the 2 sensors. The black line has to come in between these sensors. I will deal with connecting the sensors in the next step. The IR proximity sensor looks like this: http://i.ebayimg.com/images/i/201415147410-0-1/s-l...
You can even make one yourself. The working of the IR sensor is as follows. The black LED looking thing emits IR rays into the atmosphere. It is a transmitter. The white LED looking thing is a reciever. Whenever you place a reflecting surface in front of the sensor, the IR rays get reflected and detected by the detector. But if you place a non reflecting surface (for example : something black), the IR rays get absorbed and do not get detected.
Step 4: Step 4:
Attach the arduino to the chassis. Connect the ports 2, 7, 10, 15 of the IC to digital pins 6,7,10,11 respectively of the arduino. Actually you can use any pins, just make sure that the pins for forward motor movement are PWM pins. Power up the IC using the 5 volts supply of the arduino.
Connect the output ports of the left and right IR sensors to analog pins A3 and A1 respectively. Power up the sensor using the 3.3 V or 5 v from the arduino. You might need to calibrate the potentiometer in the sensor a bit with some test cases.
Step 5: Step 5:
Create a track for your robot using some black tape. You are good to go. Upload the code given below. (I am using a PWM output of 150 since the otherwise, the motor operates at such a high speed such that the robot overshoots the curves in the path). Enjoy :)
int LeftMotorForward = 6;
int LeftMotorReverse = 7;
int RightMotorForward = 10;
int RightMotorReverse = 11;
int left= A3;
int right= A1;
if(analogRead(left)<500 && analogRead(right)<500)
else if(analogRead(left)<500 && analogRead(right)>=500)
else if(analogRead(left)>=500 && analogRead(right)<500)
We have a be nice policy.
Please be positive and constructive.