This project demonstrates how to build a two-wheeled robotic car using an Arduino. The robot navigates autonomously by detecting and avoiding obstacles, using distance measurements from ultrasonic sensors.
- Arduino UNO
- HC-SR04 Ultrasonic Sensors (x3)
- Motors (x2)
- Typically included in kits with wheels, chassis, power button and 4-slot battery holder.
- L298N Motor Driver
- Power Supply
- 4-slot battery holder (for the L298N motor driver)
- 6-slot battery holder (for the Arduino)
- PlatformIO
- Trigger Pin:
- All three sensors share the same trigger pin, connected to pin 11 on the Arduino via a small breadboard.
- Echo Pins:
- Front sensor: Connect to pin 10
- Left sensor: Connect to pin 13
- Right sensor: Connect to pin 12
- Left motor: Connect to the L298N motor driver's OUT1 and OUT2.
- Right motor: Connect to the L298N motor driver's OUT3 and OUT4.
- Arduino Connections:
- Left motor: Connect ENA, IN1 and IN2 to pins 9, 8 and 7, respectively.
- Right motor: Connect IN3, IN4 and ENB to pins 5, 4 and 3, respectively.
- Build and Upload:
- Compile and upload the code to the Arduino using PlatformIO.
- Power On:
- Connect the 6-slot battery holder (with batteries obviously 😅) to the Arduino.
- Connect the 4-slot battery holder (with batteries) to the L298N motor driver.
- Turn on the L298N motor driver's power using its power button.
- Run the Robot: The robot will autonomously navigate and avoid obstacles. 🥳