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

Arduino UNO-Based Obstacle Avoidance Robot with Ultrasonic Sensors and L298N Motor Driver

Image of Arduino UNO-Based Obstacle Avoidance Robot with Ultrasonic Sensors and L298N Motor Driver

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller, an L298N DC motor driver, three HC-SR04 ultrasonic sensors, two hobby motors, a 7.4V battery, and a rocker switch. The Arduino UNO is used to control the motor driver and read data from the ultrasonic sensors. The motor driver is used to control the two hobby motors. The ultrasonic sensors are used for distance measurement.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. L298N DC Motor Driver

    • Description: A dual H-Bridge motor driver module.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  3. HC-SR04 Ultrasonic Sensor

    • Description: An ultrasonic distance sensor.
    • Pins: VCC, TRIG, ECHO, GND
  4. Motor amarillo motorreductor hobby

    • Description: A small hobby motor with a gearbox.
    • Pins: vcc, GND
  5. 7.4V Battery

    • Description: A 7.4V rechargeable battery.
    • Pins: +, -
  6. Rocker Switch

    • Description: A simple on/off switch.
    • Pins: output, input

Wiring Details

Arduino UNO

  • 5V connected to:

    • VCC of HC-SR04 Ultrasonic Sensor 1
    • VCC of HC-SR04 Ultrasonic Sensor 2
    • VCC of HC-SR04 Ultrasonic Sensor 3
  • GND connected to:

    • GND of HC-SR04 Ultrasonic Sensor 1
    • GND of HC-SR04 Ultrasonic Sensor 2
    • GND of HC-SR04 Ultrasonic Sensor 3
    • GND of 7.4V Battery
    • GND of L298N DC Motor Driver
  • Vin connected to:

    • 5V of L298N DC Motor Driver
  • D13 connected to:

    • ECHO of HC-SR04 Ultrasonic Sensor 2
  • D12 connected to:

    • TRIG of HC-SR04 Ultrasonic Sensor 2
  • D11 connected to:

    • ECHO of HC-SR04 Ultrasonic Sensor 1
  • D10 connected to:

    • TRIG of HC-SR04 Ultrasonic Sensor 1
  • D9 connected to:

    • ECHO of HC-SR04 Ultrasonic Sensor 3
  • D8 connected to:

    • TRIG of HC-SR04 Ultrasonic Sensor 3
  • D7 connected to:

    • IN4 of L298N DC Motor Driver
  • D6 connected to:

    • IN3 of L298N DC Motor Driver
  • D5 connected to:

    • ENB of L298N DC Motor Driver
  • D4 connected to:

    • IN2 of L298N DC Motor Driver
  • D3 connected to:

    • ENA of L298N DC Motor Driver
  • D2 connected to:

    • IN1 of L298N DC Motor Driver

L298N DC Motor Driver

  • GND connected to:

    • GND of Arduino UNO
    • GND of 7.4V Battery
  • 5V connected to:

    • Vin of Arduino UNO
  • OUT1 connected to:

    • GND of Motor amarillo motorreductor hobby 1
  • OUT2 connected to:

    • vcc of Motor amarillo motorreductor hobby 1
  • OUT3 connected to:

    • vcc of Motor amarillo motorreductor hobby 2
  • OUT4 connected to:

    • GND of Motor amarillo motorreductor hobby 2
  • 12V connected to:

    • output of Rocker Switch

HC-SR04 Ultrasonic Sensor 1

  • VCC connected to:

    • 5V of Arduino UNO
  • GND connected to:

    • GND of Arduino UNO
  • TRIG connected to:

    • D10 of Arduino UNO
  • ECHO connected to:

    • D11 of Arduino UNO

HC-SR04 Ultrasonic Sensor 2

  • VCC connected to:

    • 5V of Arduino UNO
  • GND connected to:

    • GND of Arduino UNO
  • TRIG connected to:

    • D12 of Arduino UNO
  • ECHO connected to:

    • D13 of Arduino UNO

HC-SR04 Ultrasonic Sensor 3

  • VCC connected to:

    • 5V of Arduino UNO
  • GND connected to:

    • GND of Arduino UNO
  • TRIG connected to:

    • D8 of Arduino UNO
  • ECHO connected to:

    • D9 of Arduino UNO

Motor amarillo motorreductor hobby 1

  • vcc connected to:

    • OUT2 of L298N DC Motor Driver
  • GND connected to:

    • OUT1 of L298N DC Motor Driver

Motor amarillo motorreductor hobby 2

  • vcc connected to:

    • OUT3 of L298N DC Motor Driver
  • GND connected to:

    • OUT4 of L298N DC Motor Driver

7.4V Battery

  • + connected to:

    • input of Rocker Switch
  • - connected to:

    • GND of Arduino UNO
    • GND of L298N DC Motor Driver

Rocker Switch

  • input connected to:

      • of 7.4V Battery
  • output connected to:

    • 12V of L298N DC Motor Driver

Code Documentation

Arduino UNO Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This code is a basic template for the Arduino UNO. The setup() function is used to initialize any settings or configurations, and the loop() function contains the main code that runs repeatedly.