Arduino-Controlled Robot with Ultrasonic Sensor and Dual DC Motors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a servo and two DC motors using an Arduino UNO microcontroller. It also includes an HC-SR04 Ultrasonic Distance Sensor for distance measurement. The Arduino UNO is powered by a 3xAAA Battery Pack and regulates power to the servo and the ultrasonic sensor. The DC motors are driven by an L298N DC motor driver, which is also powered by the battery pack. The Arduino UNO interfaces with the motor driver to control the speed and direction of the motors, and with the servo and ultrasonic sensor for their respective functions.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- Provides I/O pins for interfacing with various components
- Can be powered via USB or external power source
Servo
- A motor capable of precise position control
- Has three connections: power (VCC), ground (GND), and control signal (pulse)
DC Motor (x2)
- Electric motor that converts electrical energy into mechanical rotation
- Each motor has two connections for power and control
L298N DC Motor Driver
- A dual H-bridge motor driver capable of driving two DC motors
- Provides connections for motor power supply and control signals from the microcontroller
3xAAA Battery Pack with Switch and JST
- A power source for the circuit
- Provides a positive (POS) and negative (NEG) terminal for power distribution
HC-SR04 Ultrasonic Distance Sensor (Wokwi Compatible)
- A sensor for measuring distance via ultrasonic waves
- Has four connections: power (VCC), trigger (TRIG), echo (ECHO), and ground (GND)
Wiring Details
Arduino UNO
5Vto Servo VCC and HC-SR04 VCCGNDto Servo GND, L298N GND, HC-SR04 GND, and Battery Pack NEGVinto L298N 12V and Battery Pack POSD11to L298N ENAD10to L298N IN1D9to L298N IN2D8to L298N IN3D7to L298N IN4D6to L298N ENBD5to Servo pulseD3to HC-SR04 ECHOD2to HC-SR04 TRIG
Servo
vccto Arduino UNO 5Vgndto Arduino UNO GNDpulseto Arduino UNO D5
DC Motor #1
pin 1to L298N OUT2pin 2to L298N OUT1
DC Motor #2
pin 1to L298N OUT4pin 2to L298N OUT3
L298N DC Motor Driver
OUT1andOUT2to DC Motor #1OUT3andOUT4to DC Motor #212Vto Arduino UNO VinGNDto Arduino UNO GNDENAto Arduino UNO D11IN1to Arduino UNO D10IN2to Arduino UNO D9IN3to Arduino UNO D8IN4to Arduino UNO D7ENBto Arduino UNO D6
3xAAA Battery Pack with Switch and JST
POSto Arduino UNO VinNEGto Arduino UNO GND
HC-SR04 Ultrasonic Distance Sensor
VCCto Arduino UNO 5VTRIGto Arduino UNO D2ECHOto Arduino UNO D3GNDto Arduino UNO GND
Documented Code
Arduino UNO Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code is a template and does not contain any functional code to control the components. It needs to be populated with the appropriate setup and loop functions to initialize and control the servo, DC motors, and the ultrasonic sensor.