Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Controlled Ultrasonic Distance Measurement with Dual DC Motor Driver

Image of Arduino-Controlled Ultrasonic Distance Measurement with Dual DC Motor Driver

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with an HC-SR04 Ultrasonic Sensor and two DC Motors controlled by an L298N DC motor driver. The system is powered by a 9V Battery. The Arduino UNO is responsible for controlling the ultrasonic sensor to possibly measure distance and for driving the motors through the motor driver based on the sensor's readings or other logic implemented in the microcontroller's code.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P.
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

HC-SR04 Ultrasonic Sensor

  • An ultrasonic distance sensor that can measure distances from 2cm to 400cm with an accuracy of 3mm.
  • It has 4 pins: VCC, TRIG, ECHO, and GND.

L298N DC Motor Driver

  • A high-power motor driver capable of driving up to two DC motors.
  • It has several pins for motor outputs, power supply, and control inputs.

DC Motor (2x)

  • A standard DC motor for converting electrical energy into mechanical motion.
  • Each motor has 2 pins for electrical connections.

9V Battery

  • A standard 9V battery used to provide power to the circuit.

Wiring Details

Arduino UNO

  • 5V connected to HC-SR04 VCC.
  • GND connected to HC-SR04 GND and L298N GND.
  • Vin connected to L298N 5V.
  • Digital pins D8, D9, D10, and D11 connected to L298N IN1, IN2, IN3, and IN4 respectively.
  • Digital pin D7 connected to HC-SR04 ECHO.
  • Digital pin D6 connected to HC-SR04 TRIG.

HC-SR04 Ultrasonic Sensor

  • VCC connected to Arduino UNO 5V.
  • TRIG connected to Arduino UNO D6.
  • ECHO connected to Arduino UNO D7.
  • GND connected to Arduino UNO GND.

L298N DC Motor Driver

  • 12V connected to 9V Battery +.
  • GND connected to 9V Battery - and Arduino UNO GND.
  • 5V connected to Arduino UNO Vin.
  • IN1, IN2, IN3, and IN4 connected to Arduino UNO D8, D9, D10, and D11 respectively.
  • OUT1 and OUT2 connected to one DC Motor.
  • OUT3 and OUT4 connected to the other DC Motor.

DC Motors

  • Each motor has one pin connected to L298N OUT1 or OUT3 and the other pin to OUT2 or OUT4.

9V Battery

    • connected to L298N 12V.
    • connected to L298N 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:

}

Additional Notes

  • The provided code is a template and does not contain any functional logic. It needs to be populated with the setup and loop functions to control the HC-SR04 Ultrasonic Sensor and the DC Motors through the L298N motor driver.
  • The setup() function is used to initialize variables, pin modes, start using libraries, etc. The code will only run once after each powerup or reset of the Arduino board.
  • The loop() function is used for the main logic of the microcontroller. It runs continuously over and over again.
  • The actual implementation should include configuring the pin modes for the sensor and motor driver, reading sensor data, and controlling the motors accordingly.