This circuit is designed to control a pair of DC motors using an L298N motor driver module, interfaced with an Arduino UNO microcontroller. It also includes a Tower Pro SG90 servo motor and an ultrasonic sensor for additional functionalities such as distance measurement or object detection. The power supply for the circuit is provided by a 18650 Li-Ion battery. The Arduino UNO is responsible for controlling the behavior of the motors and the servo, as well as processing the signals from the ultrasonic sensor.
5V
pin connected to the 5V power busGND
pin connected to the ground busD5
to D11
are used to interface with the servo, ultrasonic sensor, and motor driver.Positive
terminal connected to the 12V
input of the L298N motor driverNegative
terminal connected to the ground bus5V
pin connected to the 5V power busGND
pin connected to the ground bus12V
pin connected to the positive terminal of the 18650 Li-Ion batteryIN1
to IN4
pins connected to Arduino UNO digital pins D8
to D11
OUT1
to OUT4
pins connected to the terminals of the two DC motorsSignal
pin connected to Arduino UNO digital pin D5
+5V
pin connected to the 5V power busGND
pin connected to the ground bus+VCC
pin connected to the 5V power busGND
pin connected to the ground busTrigger
pin connected to Arduino UNO digital pin D6
Echo
pin connected to Arduino UNO digital pin D7
vcc
and GND
pins connected to OUT1
and OUT2
of the L298N motor drivervcc
and GND
pins connected to OUT3
and OUT4
of the L298N motor drivervoid setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
The provided code is a template with the standard setup
and loop
functions for an Arduino sketch. The setup
function is intended to contain initialization code that runs once when the microcontroller is powered on or reset. The loop
function contains the main logic of the sketch, which runs repeatedly as long as the microcontroller is powered.
Additional code should be added to initialize the pins connected to the L298N motor driver, the servo, and the ultrasonic sensor. The logic to control the motors, read sensor data, and actuate the servo should also be implemented within the loop
function.