Arduino UNO-Based Obstacle Avoiding and Bluetooth-Controlled Robot Car
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a robot car circuit designed for obstacle avoidance, Bluetooth control, and voice control. The circuit includes an Arduino UNO microcontroller, motor and wheels, an HC-SR04 Ultrasonic Sensor, an L293D motor driver, a Micro servo 9G, a 18650 Li-Ion battery, a Bluetooth HC-06 module, and a rocker switch. The Arduino UNO is programmed to control the motors and sensors to navigate and avoid obstacles.
Component List
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
Motor and Wheels
- Description: DC motors with wheels for movement.
- Pins: vcc, GND
HC-SR04 Ultrasonic Sensor
- Description: Ultrasonic distance sensor.
- Pins: VCC, TRIG, ECHO, GND
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
Micro Servo 9G
- Description: Small servo motor.
- Pins: GND, +5V, PWM
18650 Li-Ion
- Description: Rechargeable lithium-ion battery.
- Pins: Positive, Negative
Bluetooth HC-06
- Description: Bluetooth module for wireless communication.
- Pins: VCC, GND, TXD, RXD
Rocker Switch
- Description: On/Off switch.
- Pins: output, input
Wiring Details
Arduino UNO
- Reset connected to L293D RESET
- 3.3V connected to L293D 3.3V
- 5V connected to L293D 5V
- GND connected to L293D GND
- Vin connected to L293D VIN
- 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
- D13 connected to L293D D13
- D12 connected to L293D D12
- D11 connected to L293D D11
- D10 connected to L293D D10
- D9 connected to L293D D9
- D8 connected to L293D D8
- D7 connected to L293D D7
- D6 connected to L293D D6
- D5 connected to L293D D5
- D4 connected to L293D D4
- D3 connected to L293D D3
- D2 connected to L293D D2
- D1 connected to Bluetooth HC-06 RXD and L293D TX/D1
- D0 connected to Bluetooth HC-06 TXD and L293D RX/DO
Motor and Wheels
- vcc connected to L293D +
- GND connected to L293D GND
HC-SR04 Ultrasonic Sensor
- VCC connected to L293D 5V
- TRIG connected to L293D A1
- ECHO connected to L293D A0
- GND connected to L293D GND
L293D
- RESET connected to Arduino UNO Reset
- 3.3V connected to Arduino UNO 3.3V
- 5V connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
- VIN connected to Arduino UNO Vin
- 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
- D13 connected to Arduino UNO D13
- D12 connected to Arduino UNO D12
- D11 connected to Arduino UNO D11
- D10 connected to Arduino UNO D10
- D9 connected to Arduino UNO D9
- D8 connected to Arduino UNO D8
- D7 connected to Arduino UNO D7
- D6 connected to Arduino UNO D6
- D5 connected to Arduino UNO D5
- D4 connected to Arduino UNO D4
- D3 connected to Arduino UNO D3
- D2 connected to Arduino UNO D2
- TX/D1 connected to Arduino UNO D1 and Bluetooth HC-06 RXD
- RX/DO connected to Arduino UNO D0 and Bluetooth HC-06 TXD
- + connected to Motor and Wheels vcc and Rocker Switch output
- Servo1 connected to Micro Servo 9G PWM
- A0 connected to HC-SR04 Ultrasonic Sensor ECHO
- A1 connected to HC-SR04 Ultrasonic Sensor TRIG
Micro Servo 9G
- GND connected to L293D GND
- +5V connected to L293D 5V
- PWM connected to L293D Servo1
18650 Li-Ion
- Positive connected to Rocker Switch input
- Negative connected to L293D GND
Bluetooth HC-06
- VCC connected to L293D 5V
- GND connected to L293D GND
- TXD connected to Arduino UNO D0 and L293D RX/DO
- RXD connected to Arduino UNO D1 and L293D TX/D1
Rocker Switch
- output connected to L293D +
- input connected to 18650 Li-Ion Positive
Documented Code
/*obstacle avoiding, Bluetooth control, voice control robot car.
Home Page
*/
#include <Servo.h>
#include <AFMotor.h>
#define Echo A0
#define Trig A1
#define motor 10
#define Speed 170
#define spoint 103
char value;
int distance;
int Left;
int Right;
int L = 0;
int R = 0;
int L1 = 0;
int R1 = 0;
Servo servo;
AF_DCMotor M1(1);
AF_DCMotor M2(2);
AF_DCMotor M3(3);
AF_DCMotor M4(4);
void setup() {
Serial.begin(9600);
pinMode(Trig, OUTPUT);
pinMode(Echo, INPUT);
servo.attach(motor);
M1.setSpeed(Speed);
M2.setSpeed(Speed);
M3.setSpeed(Speed);
M4.setSpeed(Speed);
}
void loop() {
Obstacle();
//Bluetoothcontrol();
//voicecontrol();
}
void Bluetoothcontrol() {
if (Serial.available() > 0) {
value = Serial.read();
Serial.println(value);
}
if (value == 'F') {
forward();
} else if (value == 'B') {
backward();
} else if (value == 'L') {
left();
} else if (value == 'R') {
right();
} else if (value == 'S') {
Stop();
}
}
void Obstacle() {
distance = ultrasonic();
if (distance <= 12) {
Stop();
backward();
delay(100);
Stop();
L = leftsee();
servo.write(spoint);
delay(800);
R = rightsee();
servo.write(spoint);
if (L < R) {
right();
delay(500);
Stop();
delay(