Safety and scope
Lift the wheels during the first motor-direction test. Keep fingers, hair and loose wires away from rotating wheels.
Plan, predict and test
Suggested virtual study time: about 25 minutes. This is a planning estimate, not a validated construction time.
Preparation: Foundation electricity and basic programming logic. Adult supervision for children. Review a foundation lesson ↗
Use paper, a spreadsheet or a simulator. This is not a verified physical assembly guide.
- Scenario: Record the actual sensor polarity over line and background. Then model all four pairs of Boolean reflectance inputs.
- Expected result: Use a truth table to choose the corresponding direction. A missing sensor must have a defined fault response.
- Checkpoint: Write your prediction, test it in the virtual model and explain any difference.
A correct answer does not certify the physical system.
Record your validation
Use only virtual inputs and indicators until the actual components, pinouts and electrical limits have been verified.
| Case | What to record |
|---|---|
| Normal input | D2/D3 both HIGH → both indicators HIGH; both LOW → both LOW |
| Boundary | LOW/HIGH → D8 LOW, D9 HIGH; HIGH/LOW → reverse |
| Missing or invalid input | Unplugged pull-up input can read HIGH; the sketch cannot distinguish this fault. Do not connect motors. |
| Repeat test | Repeat the virtual test, record the actual output and compare with the expected result. |
These are test-planning requirements, not recorded hardware results.
Before building: understand the listed components and the relevant low-voltage safety rules. This is a concept brief, not a tested assembly manual.
What it does
Build a mobile robot that can keep itself centred over a marked route without a person steering it.
Engineering principle
Infrared reflectance sensing. A light surface reflects more IR while a dark line reflects less. Two or more reflectance sensors provide left/right position information. The controller turns that difference into motor corrections. A basic build uses threshold decisions; a tuned version can calculate line-position error and apply PID control to reduce overshoot.
Hardware and components
- Arduino NanoReads the sensors and calculates motor commands.
- 2 × IR reflectance modulesTCRT5000-type modules sit near the floor and detect the line. Output polarity varies by module; calibrate on the actual surface.
- L298N H-bridge driverSwitches motor current and direction; the microcontroller pins do not power the motors directly.
- 2 × BO geared DC motors + wheelsProvide differential drive so the robot can steer by changing each side’s speed.
- Chassis, battery pack and wiringHold the assembly and supply separate logic/motor power as required.
Suggested build sequence
- Mount the sensors low and evenly spaced ahead of the wheels.
- Calibrate the sensors over both the track and background; confirm whether black reads HIGH or LOW on the chosen module.
- Wire the motor driver, logic supply and motor supply; verify the grounds and polarity before connecting the battery.
- Start with slow threshold-based steering, then tune motor speed and correction response.
- If the track and hardware justify it, calculate line error and tune a PID controller.
Learning outcomes
- IR sensor calibration
- H-bridge motor direction and PWM
- Differential steering
- Feedback and PID fundamentals
Possible upgrades
Add a multi-channel sensor array, intersection recognition, speed profiles, lost-line recovery and a PID tuning mode.
Practice the core principle
This simplified exercise is not the full physical project shown above. Test in simulation first; verify real hardware against its datasheet. Children need adult supervision.
Reference components
- Arduino Uno
- 2 pushbuttons
- 2 LEDs
- 2 × 330 Ω resistors
Connection plan
- Left virtual sensor switch D2 → GND
- Right virtual sensor switch D3 → GND
- Left indicator D8 → 330 Ω → LED → GND
- Right indicator D9 → 330 Ω → LED → GND
Reference sketch
void setup(){
pinMode(2,INPUT_PULLUP); pinMode(3,INPUT_PULLUP);
pinMode(8,OUTPUT); pinMode(9,OUTPUT);
}
void loop(){
bool left=digitalRead(2)==LOW;
bool right=digitalRead(3)==LOW;
digitalWrite(8,!left);
digitalWrite(9,!right);
delay(20);
}How the code works
- Inputs represent hypothetical calibrated line sensors.
- LOW represents a pressed switch.
- Each LED represents one motor command, not a powered motor.
- This simple truth table is for reasoning practice, not a validated line-following controller.
Practice sequence
- Assemble the switch and LED circuit with power disconnected.
- Simulate four combinations of sensor inputs.
- Record the corresponding indicator commands.
- For a physical rover, choose rated drivers and calibrated sensors under qualified supervision.
Expected result
Create a truth table and verify each virtual motor command.
Troubleshooting
Check input pull-ups and LED polarity; do not connect motors to output pins.
Independent challenge
Design lost-line behaviour and discuss how sensor placement changes steering.