Built during the Robotics track, this was a collaborative project involving two students. The robot uses two infra-red sensors to detect the boundary between a black line and white surface, adjusting motor speed to stay on course.
Hardware used
- Arduino Uno microcontroller
- L298N dual H-bridge motor driver
- 2× IR proximity sensors
- 2× DC gear motors + chassis kit
- 7.4V LiPo battery pack
How it works
Each sensor returns a HIGH signal when it detects white and LOW over black. A simple decision tree in the loop function steers the robot: both sensors on white = go straight, left sensor on black = turn left, right sensor on black = turn right.
void loop() {
int leftVal = digitalRead(LEFT_SENSOR);
int rightVal = digitalRead(RIGHT_SENSOR);
if (leftVal == HIGH && rightVal == HIGH) forward();
else if (leftVal == LOW) turnLeft();
else if (rightVal == LOW) turnRight();
}