Summary:
Sometimes electronics enthusiasts have ideas for building robots from animals in the wild. There are robot dogs, robot snakes, robot birds, and even robotic insects! In this project, you will build your own robot that will automatically chase a light source, mimicking a behavior called phototaxis seen in some insects and flowers. This is a robot that chases light, for this to work the robot needs at least two light detection sensors, in front and spaced apart from each other.
Figure 1: Prototype light following Arduino robot
Description:
Prerequisites and equipment:
You will need the following:
-
An Arduino board or Arduino clone (here's a guide if you need it)
-
Two DC motors.
-
A 5v TTL-UART Bluetooth module.
-
Robot chassis and wheels that adapt to the size of the chassis and motor.
-
Arduino IDE for programming.
Working principle:
Arduino Clone is used here to read the light intensity of these two photoresistors and make a comparison and direct the robot in the direction of light. For example, if both photoresistors are getting lighter, the robot should drive in a straight line. If the right photoresist or receives more light than the right robot, it should turn to the right.
Another specialty of this project is by using the same code and some modifications in the hardware we can make the robot avoid objects, by tilting the Photoresistor to the ground so that we can take advantage of the shadows of the object to avoid the object avoiding the darkness.
This Photovore robot can also be changed to a Photophobe robot simply by inverting the connection of the motors, that is, connecting the right motor to the left and also inverting the positive and negative terminals.
Figure 2: Block diagram of the light following the Arduino robot
The sensor we are using here is a light-dependent resistor (LDR) that exhibits photoconductivity. Its resistance increases with decreasing light intensity and vice versa. To use them as a sensor, we have to measure the voltage drop across the LDR. Because change in resistance means a change in voltage.
Two different ways of the voltage divider principle to implement this is to increase the voltage with light. (R*Vin)/(R+Rfoto) = Vout
Figure 3: Circuit Diagram of Light Sensitive Voltage Divider Network
Another is the decrease in tension with light. (Rphoto *Vin)/(R+Rphoto) = Vout
Fig. 4: Circuit diagram of dark-sensitive voltage divider network
There are three steps to determining which resistor we should use for R. To do this, we first need to measure the resistance in the photoresistor in two situations using a multimeter. The first situation is the Robot's darkest light. The second situation is the brighter light on the Robot. Now, we need to multiply the two resistance values, finding the square root of the total will give the resistor value you should use.
Hardware assembly:
Make the circuit as shown in the circuit diagram. Assemble the robot with the selected parts and connect the motors to the circuit. Optocouplers are used to protect Arduino from high voltage hazards.
Code description:
empty configuration {
sensorValue1 = analogRead(LDR1);
sensorValue2 = analogRead(LDR2);
LEFT = sensorValue1/100;
RIGHT = sensorValue2/100;
N LEFT = LEFT;
NR RIGHT = RIGHT;
}
The above part of the code is to measure the normal light intensity and store this value for future comparison and make the robot stable.
The conditions below are used to navigate the Robot:
if ((LEFT == N LEFT) && (RIGHT == NR RIGHT))
Condition to compare current LDR values with normal LDR values, to stop the robot when there is no change.
if ((LEFT > N LEFT) && (RIGHT > NR RIGHT)&&(RIGHT == LEFT))
Condition to move the robot forward if both LDR values are increased.
if ((RIGHT > LEFT)&&((LEFT > NLEFT) (RIGHT > NR RIGHT)))
Condition to move the robot to the right if both LDR values are increased.
if ((LEFT > RIGHT)&&((LEFT > NLEFT) (RIGHT > NR RIGHT)))
Condition to move the robot to the left if both LDR values are increased.
Circuit diagrams
Arduino Based Light Following Robot Circuit Diagram |
Project video