In this lesson, we will use a servo motor, a photoresistor and a pull-down resistor to assemble an automatically tracking light source system, this lesson from a hardware point of view is none other than a compilation of some previous lessons, we are depending more on the code this time to achieve our goal.


- 1 Uno board
- 1 Servo motor
- 1 Photoresistor
- 1 Resistor (10KΩ)
- Several jumper wires
- 1 USB data cable

Experimental Principle

The servo motor and the photoresistor scan and look for light source in 180 degree and record the location of light source. After finishing scanning, the servo motor and the photoresistor stop at the direction of light source.

Experimental Procedures

Step 1: Connect circuit as shown in the Fig1. The corresponding schematic diagram is in Fig2. (Schematic is generated by EAGLE)

circuit connection

Fig1: the connection of the servo, motor and (LDR)

eagle schematic

Fig2: the schematic

Note: you need to bind one end of the resistor and photoresistor to the wing of the servo, as shown below:

LDR position

Fig3: the position of the LDR

Step 2: Program the Arduino (download program from documents).
Step 3: Compile the program.
Step 4: Burn the program into the Uno board.

Now, if you use a flashlight to shine the photoresistor, you will see the servo motor and the photoresistor rotate, finally stop at the direction of light source.

Experiment summary

This lesson combines between the servo motor and the photoresistor (LDR) lessons to generate a third useful lesson, such tracking systems are used in robots for obstacles detection.


1-Arduino progrme (code)
2-Eagle file
3-Arduino Servo library