Arduino Light Seeking Robot(7$)
Friday, August 28, 2015Here I'am showing how to make a arduino light seeking(follower) robot . Made using arduino pro mini it's very cheap I ally used 7$ (450 Indian rupee) to make this robot. This robot can find the door of the house by following light.
Let's start making
Parts you need
* Arduino pro mini
* PCB dot board
* 2* Dc hobby motor
* 2* 2n222 transistor or BC547
* 2*10k resister
* 2* In4001 or In4007 Diod
* 2*LDR
* 2*LDR
The circuit diagrem
Connecting all together
![]() |
Connecting the motor controller and soldering it |
![]() |
Connecting the arduino pro mini |
![]() |
Connecting the LDR sensors |
![]() |
Connecting the motor |
![]() |
Connecting a small wheel on friend side |
Ready to program
Upload this program and start play
// Pin definitions - attaches a variable to a pin.
const int RightMotor = 4; // This pin is used to enable or disable the Right motor. Connected to the base of an NPN transistor.
const int LeftMotor = 6; // This pin is used to enable or disable the Left motor. Connected to the base of an NPN transistor.
const int RightSensor = 0; // This pin is used to read the value of the Right Sensor.
const int LeftSensor = 1; // This pin is used to read the value of the Left Sensor.
// Variable definitions
int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch
int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch
int SensorDifference; // This value is used to determine the difference between the Left and Right
// the setup() method runs once when the program is run. When the
// Arduino is reset, the setup() will be executed once again.
void setup() {
pinMode(LeftMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(RightMotor, OUTPUT); // Defines this pin as an output. The Arduino will write values to this pin.
pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.
digitalWrite(A0, HIGH); // Enables an internal pullup resistor
digitalWrite(A1, HIGH); // Enables an internal pullup resistor
Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600
Serial.println(" \nBeginning Light Seeking Behavior"); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop() {
SensorLeft = 1023 - analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorRight = 1023 - analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.
delay(1);
SensorDifference = abs(SensorLeft - SensorRight); // This calculates the difference between the two sensors and then saves it to an integer.
// This section of the sketch is used to print the values of the
// sensors through Serial to the computer. Useful for determining
// if the sensors are working and if the code is also functioning properly.
Serial.print("Left Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorLeft); // Prints the value of the Left Sensor.
Serial.print("\t"); // Prints a tab (space).
Serial.print("Right Sensor = "); // Prints the text inside the quotes.
Serial.print(SensorRight); // Prints the value of the Right Sensor.
Serial.print("\t"); // Prints a tab (space).
// This section of the sketch is what actually interperets the data and then runs the motors accordingly.
if (SensorLeft > SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads more light than the Right Sensor, Do this:
digitalWrite(RightMotor, HIGH); // This is used to turn Left. Notice the
digitalWrite(LeftMotor, LOW); // opposite motor runs to turn Left.
Serial.println("Left"); // This prints Left when the robot would actually turn Left.
}
if (SensorLeft < SensorRight && SensorDifference > 75) { // This is interpreted as if the Left sensor reads less light than the Right Sensor, Do this:
digitalWrite(RightMotor, LOW); // This is used to turn Right. Notice the
digitalWrite(LeftMotor, HIGH); // opposite motor runs to turn Right.
Serial.println("Right"); // This prints Right when the robot would actually turn Right.
}
else if (SensorDifference < 75) { // This is interpreted as if the difference between the two sensors is under 125 (Experiment to suit our sensors), Do this:
digitalWrite(RightMotor, HIGH); // This is used to go straight. Notice
digitalWrite(LeftMotor, HIGH); // both motors are enabled to go forward.
Serial.println("Forward"); // This prints Forward when the robot would actually go forward.
}
Serial.print("\n");
}
0 comments
Click on 'Notify me' to get replies of your comment.