Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and L293D Motor Driver-Based Battery-Powered Dual Motor Control with Hall Sensors and LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino UNO and L293D Motor Driver-Based Battery-Powered Dual Motor Control with Hall Sensors and LED Indicators

Circuit Documentation

Summary

This circuit is designed to control two DC motors and three LEDs using an Arduino UNO microcontroller. The circuit also includes three Hall sensors to detect magnetic fields and control the motors and LEDs accordingly. The L293D motor driver is used to drive the DC motors, and resistors are used to limit the current through the LEDs and Hall sensors. A 9V battery powers the entire circuit.

Component List

  1. Arduino UNO

    • Description: 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. L293D Motor Driver

    • Description: Dual H-Bridge motor driver IC.
    • Pins: enable 1, input 1, output 1, gnd, output 2, input 2, vs, vss, input 4, output 4, output 3, input 3, enable 2
  3. DC Motor

    • Description: Standard DC motor.
    • Pins: pin 1, pin 2
  4. 9V Battery

    • Description: Power source for the circuit.
    • Pins: -, +
  5. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  6. Resistor

    • Description: Resistor with a resistance of 200 Ohms.
    • Pins: pin1, pin2
  7. Hall Sensor

    • Description: Sensor to detect magnetic fields.
    • Pins: -, +, S

Wiring Details

Arduino UNO

L293D Motor Driver

DC Motor 1

DC Motor 2

9V Battery

LED 1

LED 2

LED 3

Resistor 1

Resistor 2

Resistor 3

Hall Sensor 1

Hall Sensor 2

Hall Sensor 3

Code Documentation

Arduino UNO Code

const int hallSensor1 = A0;
const int hallSensor2 = A1;
const int hallSensor3 = A2;
const int motor1Pin1 = 5;
const int motor1Pin2 = 6;
const int motor2Pin1 = 7;
const int motor2Pin2 = 8;
const int led1Pin = 3;
const int led2Pin = 2;
const int led3Pin = 12;

void setup() {
  pinMode(hallSensor1, INPUT);
  pinMode(hallSensor2, INPUT);
  pinMode(hallSensor3, INPUT);
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin1, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  pinMode(led3Pin, OUTPUT);
}

void loop() {
  int sensor1Value = digitalRead(hallSensor1);
  int sensor2Value = digitalRead(hallSensor2);
  int sensor3Value = digitalRead(hallSensor3);

  digitalWrite(led1Pin, sensor1Value == HIGH ? HIGH : LOW);
  digitalWrite(led2Pin, sensor2Value == HIGH ? HIGH : LOW);
  digitalWrite(led3Pin, sensor3Value == HIGH ? HIGH : LOW);

  if (sensor1Value == HIGH) {
    digitalWrite(motor1Pin1, HIGH);
    digitalWrite(motor1Pin2, LOW);
  } else {
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, LOW);
  }

  if (sensor2Value == HIGH) {
    digitalWrite(motor2Pin1, HIGH);
    digitalWrite(motor2Pin2, LOW);
  } else {
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, LOW);
  }

  if (sensor3Value == HIGH) {
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, HIGH);
  }
}

DC Motor Code