Arduino UNO and L293D Motor Driver-Based Battery-Powered Dual Motor Control with Hall Sensors and LED Indicators
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control two DC motors and three LEDs using an Arduino UNO. 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 motors, and resistors are used to limit the current through the LEDs and Hall sensors. A 9V battery powers the circuit.
Component List
L293D Motor Driver
- Description: Motor driver IC used to control the direction and speed of two DC motors.
- Pins: enable 1, input 1, output 1, gnd, output 2, input 2, vs, vss, input 4, output 4, output 3, input 3, enable 2
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
DC Motor
- Description: Standard DC motor.
- Pins: pin 1, pin 2
9V Battery
- Description: Power source for the circuit.
- Pins: -, +
LED: Two Pin (red)
- Description: Red LED.
- Pins: cathode, anode
Resistor
- Description: Resistor with a resistance of 200 Ohms.
- Pins: pin1, pin2
Hall Sensor
- Description: Sensor used to detect magnetic fields.
- Pins: -, +, S
Wiring Details
L293D Motor Driver
gnd connected to:
- Resistor pin1
- Hall Sensor +
- 9V Battery -
- Arduino UNO GND
vss connected to:
- Arduino UNO 5V
vs connected to:
- 9V Battery +
enable 1 connected to:
- Arduino UNO D10
input 1 connected to:
- Arduino UNO D5
output 1 connected to:
- DC Motor pin 1
output 2 connected to:
- DC Motor pin 2
input 2 connected to:
- Arduino UNO D6
input 4 connected to:
- Arduino UNO D7
output 4 connected to:
- DC Motor pin 1
output 3 connected to:
- DC Motor pin 2
input 3 connected to:
- Arduino UNO D8
enable 2 connected to:
- Arduino UNO D11
Arduino UNO
GND connected to:
- L293D Motor Driver gnd
5V connected to:
- L293D Motor Driver vss
D3 connected to:
- LED anode
D2 connected to:
- LED anode
D12 connected to:
- LED anode
A0 connected to:
- Hall Sensor S
- Resistor pin1
A1 connected to:
- Hall Sensor S
- Resistor pin1
A2 connected to:
- Hall Sensor S
- Resistor pin1
D10 connected to:
- L293D Motor Driver enable 1
D5 connected to:
- L293D Motor Driver input 1
D6 connected to:
- L293D Motor Driver input 2
D7 connected to:
- L293D Motor Driver input 4
D8 connected to:
- L293D Motor Driver input 3
D11 connected to:
- L293D Motor Driver enable 2
DC Motor
pin 1 connected to:
- L293D Motor Driver output 1
- L293D Motor Driver output 4
pin 2 connected to:
- L293D Motor Driver output 2
- L293D Motor Driver output 3
9V Battery
- connected to:
- L293D Motor Driver gnd
+ connected to:
- L293D Motor Driver vs
LED: Two Pin (red)
anode connected to:
- Arduino UNO D3
- Arduino UNO D2
- Arduino UNO D12
cathode connected to:
- Resistor pin2
Resistor
pin1 connected to:
- Hall Sensor +
- Hall Sensor S
- Arduino UNO A0
- Arduino UNO A1
- Arduino UNO A2
pin2 connected to:
- Hall Sensor -
- LED cathode
Hall Sensor
+ connected to:
- Resistor pin1
- connected to:
- Resistor pin2
S connected to:
- Resistor pin1
- Arduino UNO A0
- Arduino UNO A1
- Arduino UNO A2
Documented Code
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
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This documentation provides a comprehensive overview of the circuit, including a summary, component list, wiring details, and documented code.