Home > Circuit Blox > Line Following Buggy

UPDATED:.21:10 02 January 2019

This circuit will activate a motor when the LDR detects a certain level of light.

To use this in a Line Following Buggy you need 2 of the circuits below. The LDRs are mounted about 300mm apart with an LED lit between them facing the floor. The left LDR controls the right motor and vice verca. The buggy should follow a white line against a dark background.

If the buggy drifts left, the right motor stops, causing the left motor to make the buggy pivot around the right wheel until the line is found again. When the strip runs out, the buggy will stop.

Circuit Voltage: 4.5 to 12 volts

Light Sensor:
Set VR1 at the mid point.

Comparator Switch:
Try using the Schmitt on or off to suit certain conditions. VR1 sets the light level required to enable motor to run. Adjust VR1 so that the motor switches off when the buggy drifts off line.

For reliable operation, use 3 x100nF capacitors between the motor connections and the case. Motors produce very strong electrical interference.

The white line on the floor should contrast as much as possible from the flooring beneath it. Setting the correct brightness for the LED is also important.



The light sensor produces a voltage proportional to the light upon it. The more light, the higher the voltage.

This voltage is connected to the Comparator Switch so that when the light level reaches a certain point, the voltage is greater than the reference voltage set by VR1, so the output switches on.

The output from the Comparator Switch is connected to a Darlington Driver which boosts the current to drive the motor.

The motor will switch off if the light on the LDR on the opposite side drops below a certain level. This can happen very briefly so that you only just notice a change in pitch from the motor.

Topics covered could be:
  • Motor reversing using DPDT switch/relay
  • Gears and gearboxes - calculating gear ratios and spees.
  • Light sensors and Potential Dividers
  • Operational Amplifiers as comparators.
  • Other forms of direction control such collision detection

Methods of improving performance, such as:
  • Shielding the sensor area beneath the droid from ambient light
  • Altering intensity of LED.
  • Altering the position and angle of LDRs
  • Adjusting the height of sensors from floor
  • Changing strip colours and LED colours.

Other forms of guidance can be used such as a magnetic strip and hall sensors - although magnetic strip may prove expensive.