A Line Follower + Obstacle Avoiding Robot Car Controlled by IR Remote & Mobile App
Welcome to the Arduino All-in-One Robot project!
This multipurpose robot combines line following, obstacle avoidance, and remote/mobile control into a single platform. It can be operated using:
- ๐๏ธ IR Remote (MP3 remote with custom button mapping)
- ๐ฑ Android App (built with MIT App Inventor, includes Bluetooth & voice control)
This project is perfect for students, hobbyists, and robotics enthusiasts who want to explore autonomous navigation and interactive control systems.
- โ Line Follower Mode โ Follows black/white paths using IR sensors
- โ Obstacle Avoidance Mode โ Detects and avoids obstacles with ultrasonic sensor
- โ Manual Control โ Operated via IR remote or Android app
- โ Voice Commands โ Control robot with speech recognition
- โ Speed Control โ Adjustable via mobile app slider
- โ DIY Friendly โ Easy to assemble with common Arduino components
| Component | Quantity |
|---|---|
| 5mm Acrylic Sheet (20cm x 12cm) | 1 |
| DC Gear Motor | 4 |
| Arduino UNO | 1 |
| IR Sensor | 2 |
| L298 Motor Driver | 1 |
| HC-05 Bluetooth Module | 1 |
| IR Receiver Module | 1 |
| MP3 Player IR Remote | 1 |
| SG90 Servo Motor | 1 |
| Ultrasonic Sensor HC-SR04 + Holder | 1 |
| Robot Car Wheels | 4 |
| Jumper Wires (M-F) | As needed |
| On/Off Switch | 1 |
| 18650 Battery Holder (2-cell) | 1 |
| 18650 Li-ion Battery (3.7V) | 2 |
- Power Supply: 2 ร 18650 batteries in series (7.4V)
- Microcontroller: Arduino UNO
- Motor Driver: L298N for left & right motors
- Sensors:
- IR sensors โ Line following
- Ultrasonic sensor โ Distance measurement
- Control Modules:
- HC-05 Bluetooth โ Mobile app control
- IR Receiver โ Remote control
- Servo Motor: Rotates ultrasonic sensor for scanning
โฒโ Move Forwardโผโ Move Backwardโถโ Turn Rightโโ Turn Left1โ Manual Mode2โ Line Follower Mode3โ Obstacle Avoidance Mode
- Buttons: Forward, Backward, Left, Right, Stop
- Voice Commands: โGo Forwardโ, โStopโ, โGo Backโ, โTurn Rightโ, โTurn Leftโ
- Modes: Line Following, Obstacle Avoidance, Manual
- Slider: Adjust robot speed
| App Control (MIT Block) | Data Sent (1โByte Number) | Arduino Code Interprets As | Robot Action |
|---|---|---|---|
| Forward (TouchDown) | 1 |
bt_ir_data == 1 |
Move Forward |
| Backward (TouchDown) | 2 |
bt_ir_data == 2 |
Move Backward |
| Left (TouchDown) | 3 |
bt_ir_data == 3 |
Turn Left |
| Right (TouchDown) | 4 |
bt_ir_data == 4 |
Turn Right |
| Stop (manual mode only) / Button Release (TouchUp) | 0 |
bt_ir_data == 0 โ Stop (manual mode only) |
Stop (manual mode only) Motors |
| Stop (manual mode only) Button (optional) | 5 |
bt_ir_data == 5 |
Stop (manual mode only) Motors |
| Voice Left | 6 |
bt_ir_data == 6 |
Short Left Turn (momentary) |
| Voice Right | 7 |
bt_ir_data == 7 |
Short Right Turn (momentary) |
| Manual Mode | 8 |
mode = 0 |
Switch to Manual Control |
| Line Follower Mode | 9 |
mode = 1 |
Enable Line Following |
| Obstacle Avoid Mode | 10 |
mode = 2 |
Enable Obstacle Avoidance |
| Slider (Speed Control) | 21โ255 |
Speed = data |
Adjust Motor Speed (PWM) |
- Install the provided APK on your Android device
- Or import the AIA file into MIT App Inventor to customize
- Connect via Bluetooth (HC-05) โ Default pairing code usually
1234or0000
- Install Arduino IDE
- Install IRremote (the sketch uses its v3-style
IrReceiverAPI) and Servo;SoftwareSerialis supplied by the Arduino AVR core - Select Arduino UNO board & correct COM port
- Upload the provided
.inocode - Power the robot and test each mode
The table follows AIOR.ino; confirm the physical wiring against schematic.png before connecting power.
| Connection | Arduino Uno pin |
|---|---|
| HC-05 TX โ Uno software RX | D2 |
| Uno software TX โ HC-05 RX | D3 (use a suitable logic-level divider) |
| L298N right enable / IN1 / IN2 | D10 / D9 / D8 |
| L298N left enable / IN3 / IN4 | D5 / D7 / D6 |
| Right / left line sensor | A0 / A1 |
| HC-SR04 echo / trigger | A2 / A3 |
| Scanning servo signal | A4 |
| IR receiver signal | A5 |
Bluetooth and USB diagnostic serial both use 9600 baud. Motor power must use the driver supply; connect controller, sensor and driver grounds together.
There are three firmware states. Voice turns (6 and 7) are actions within manual control.
stateDiagram-v2
[*] --> Manual
Manual --> LineFollower: byte 9
Manual --> ObstacleAvoid: byte 10
LineFollower --> Manual: byte 8
LineFollower --> ObstacleAvoid: byte 10
ObstacleAvoid --> Manual: byte 8
ObstacleAvoid --> LineFollower: byte 9
The IR button labels vary by remote. The firmware maps raw 0xFF30CF to manual, 0xFF18E7 to line following and 0xFF7A85 to obstacle avoidance. Use the serial output to check your remote's codes; the app's byte table above is the firmware contract.
- The servo helper now normalizes the step sign. The descending
140 โ 0startup/scan calls previously increased the angle instead of completing. - Turns and scanning use blocking delays. Bytes
0/5stop the motors only in manual mode. Autonomous modes ignore those stop bytes; send byte8to return to manual and stop once input polling resumes. There is no independent emergency-stop or lost-connection timeout. - A missing ultrasonic echo returns 400 cm. Obstacle mode treats that as clear space and can drive forward; it cannot distinguish a disconnected sensor from an out-of-range obstacle.
- On a classic ATmega328P Uno, the Servo library uses Timer1, which conflicts with PWM on D9/D10. The right motor enable is D10. This requires a reviewed wiring/timer change before relying on independent motor speed control; this update does not change the pinout.
- Selecting line-following or obstacle mode sets its default speed again while the mode-select command remains the last command. Slider behavior therefore needs a device check in each mode.
For initial checks, lift the wheels clear of the surface and keep motor power easy to disconnect. The host regression check verifies the servo angle sequence only:
# Python 3 and g++ required; no Arduino board connected.
python3 -m unittest discover -s tests -vFirmware upload, motor polarity, sensor thresholds, IR decoding and timing still require the physical build. The configured scan is 70 โ 140 โ 0 โ 70, rather than a full 180-degree sweep.
- Calibrate IR sensors for black/white surface detection
- Test IR remote buttons for movement & mode switching
- Verify Bluetooth connection with mobile app
- Test voice commands and speed control
- Understanding of autonomous navigation
- Integration of sensors, actuators, and wireless modules
- Hands-on experience with Arduino programming
- Exposure to MIT App Inventor mobile app development
The sketch, App Inventor source, APK, schematic and build photos are included. Use the pinout and limitations above when adapting the build; the photos and demo are separate from the host regression check.
This project is licensed under the Apache License 2.0 โ see the LICENSE file for details.

