Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to control a set of motors using an Arduino UNO and an L293D motor driver. The circuit also includes an HC-06 Bluetooth module for wireless communication and a 9V battery for power supply. The Arduino UNO is programmed to control the motors based on commands received via Bluetooth.
Component List
L293D
- Description: Motor driver IC
- Pins: 5V, GND, +, Servo1, Servo2, RX/DO, TX/D1, 9V, A0, A1, A2, A3, A4/SDA, A5/SCL, VIN, 3.3V, RESET, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13
Arduino UNO
- Description: Microcontroller board
- 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
HC-06
- Description: Bluetooth module
- Pins: RXD, TXD, GND, VCC
Motor and Wheels
- Description: DC motor with wheels
- Pins: vcc, GND
9V Battery
- Description: Power supply
- Pins: -, +
Wiring Details
L293D
GND connected to:
- 9V Battery (-)
- Motor and Wheels (GND) x4
- HC-06 (GND)
- Arduino UNO (GND) x3
- Arduino UNO (AREF)
5V connected to:
- HC-06 (VCC)
- Arduino UNO (5V)
+ connected to:
- 9V Battery (+)
- Motor and Wheels (vcc) x4
RX/DO connected to:
- HC-06 (TXD)
- Arduino UNO (D0)
TX/D1 connected to:
- HC-06 (RXD)
- Arduino UNO (D1)
A0 connected to:
- Arduino UNO (A0)
A1 connected to:
- Arduino UNO (A1)
A2 connected to:
- Arduino UNO (A2)
A3 connected to:
- Arduino UNO (A3)
A4/SDA connected to:
- Arduino UNO (A4)
A5/SCL connected to:
- Arduino UNO (A5)
VIN connected to:
- Arduino UNO (Vin)
3.3V connected to:
- Arduino UNO (3.3V)
RESET connected to:
- Arduino UNO (Reset)
D2 connected to:
- Arduino UNO (D2)
D3 connected to:
- Arduino UNO (D3)
D4 connected to:
- Arduino UNO (D4)
D5 connected to:
- Arduino UNO (D5)
D6 connected to:
- Arduino UNO (D6)
D7 connected to:
- Arduino UNO (D7)
D8 connected to:
- Arduino UNO (D8)
D9 connected to:
- Arduino UNO (D9)
D10 connected to:
- Arduino UNO (D10)
D11 connected to:
- Arduino UNO (D11)
D12 connected to:
- Arduino UNO (D12)
D13 connected to:
- Arduino UNO (D13)
Arduino UNO
GND connected to:
- L293D (GND) x3
5V connected to:
- L293D (5V)
3.3V connected to:
- L293D (3.3V)
Vin connected to:
- L293D (VIN)
Reset connected to:
- L293D (RESET)
D0 connected to:
- HC-06 (TXD)
- L293D (RX/DO)
D1 connected to:
- HC-06 (RXD)
- L293D (TX/D1)
A0 connected to:
- L293D (A0)
A1 connected to:
- L293D (A1)
A2 connected to:
- L293D (A2)
A3 connected to:
- L293D (A3)
A4 connected to:
- L293D (A4/SDA)
A5 connected to:
- L293D (A5/SCL)
AREF connected to:
- L293D (GND)
HC-06
GND connected to:
- L293D (GND)
VCC connected to:
- L293D (5V)
RXD connected to:
- Arduino UNO (D1)
- L293D (TX/D1)
TXD connected to:
- Arduino UNO (D0)
- L293D (RX/DO)
Motor and Wheels
GND connected to:
- L293D (GND) x4
vcc connected to:
- L293D (+) x4
9V Battery
- connected to:
- L293D (GND)
+ connected to:
- L293D (+)
Code Documentation
#include <AFMotor.h>
//initial motors pin
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command;
void setup()
{
Serial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop(){
if(Serial.available() > 0){
command = Serial.read();
Stop(); //initialize with motors stopped
//Change pin mode only if new command is different from previous.
//Serial.println(command);
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255);//Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255);//Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void Stop()
{
motor1.setSpeed(0); //Define minimum
