Introduction: Simple Bluetooth Car With Ultrasonic Parking Siren
Hiiiiiiiiiiiiiiiii Its my first instructable with arduino. I have made a simple bluetooth car along with it i have made ultrasonic parking sensor.
Step 1: Materials Required: -
1. Chassis
2. 2 DC Motors
3. Wires
4. Hollow Metal pipe
5. 4 Wheels
6. 2 Arduino UNO
7. Jumper wires
8. 2 PCBs
9. Ultrasonic Sensor(HC-SR04)
10. Male Female headers
11. LEDs
12. Piezo Buzzer
13. Bluetooth module(HC-05)
14. L293D MOTOR IC
15. Solar Panel
16. 2 4v Lead acid Battery
17. 9v Rechargeable battery
18. Arduino Power Jack
19. Wire stripper
20. Soldering Wires
21. Soldering iron
22. Male to male headers
23. Android phone( with Bluetooth RC Controller.apk)
Step 2: Construction: -
First we
will make ultrasonic parking siren.
For making Ultrasonic parking sensor we need the following things: -
1. Breadboard
2. Jumper wire
3. Buzzer
4. Ultrasonic Sensor
5. LEDs
6. Arduino UNO
Step 1: FIRST Connect the GND pin on the sensor to the GND pin on the Arduino THEN connect the Vcc pin on the sensor to the 5V pin on the Arduino
Step 2: Connect the Echo pin of the sensor to Pin 3 of the Arduino
Step 3: Connect the Trig pin of the sensor to Pin 4 of the Arduino
Step 4: Connect the +ve terminal of buzzer to the 11 pin of the Arduino
Step 5: Connect the -ve terminal of buzzer to the GND pin of the Arduino
Step 6: Connect the +ve terminal of LED to the 11 pin of the Arduino
Step 5: Connect the -ve terminal of LED to the GND pin of the Arduino
Step 6: Load the “Ultrasonic Siren Program” written below
Codes are: -
// codes start from here
int sirenPin = 11;
long duration;
void setup() {
pinMode(4,OUTPUT); // trig pin
pinMode ( 3,INPUT); // echo pin
pinMode (sirenPin,OUTPUT); // set the siren pin as output
//Serial.began(9600); // display distance OPTIONAL
}
void loop()
{
//*********code measures time for the sound to bounce back from an object**********
digitalWrite(4,HIGH); // turn on trigger
delayMicroseconds(5);
digitalWrite(4, LOW); //turn trigger off
duration = pulseIn(3, HIGH); // measure time for sound wave to come back
//Serial.print(duration/58); // converts microseconds into centimeters //OPTIONAL
//Serial.printIn("cm"; // OPTIONAL
digitalWrite(sirenPin, HIGH); //turn siren o
delay(200); //leave on for 100 milliseconds
digitalWrite(sirenPin,LOW); //turn siren off
delay(duration/40); //leave off depending on distance
}
// codes end here
Now we will use Bluetooth module to control the car.
Make the circuit using the picture given.
After making
this circuit upload these codes on your Arduino Uno: -
// codes start here
/*
* created by kartik verma
* Control 2 DC motors with Smartphone via bluetooth
*/
int motor1Pin1 = 3; // pin 2 on L293D IC
int motor1Pin2 = 4; // pin 7 on L293D IC
int enable1Pin = 6; // pin 1 on L293D IC
int motor2Pin1 = 8; // pin 10 on L293D IC
int motor2Pin2 = 9; // pin 15 on L293D IC
int enable2Pin = 11; // pin 9 on L293D IC
int state;
int flag=0; //makes sure that the serial only prints once the state
int stateStop=0;
void setup() {
// sets the pins as outputs:
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enable1Pin, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enable2Pin, OUTPUT);
// sets enable1Pin and enable2Pin high so that motor can turn on:
digitalWrite(enable1Pin, HIGH);
digitalWrite(enable2Pin, HIGH);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
//if some date is sent, reads it and saves in state
if(Serial.available() > 0){
state = Serial.read();
flag=0;
}
// if the state is 'F' the DC motor will go forward
if (state == 'F') {
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
if(flag == 0){
Serial.println("Go Forward!");
flag=1;
}
}
// if the state is 'L' the motor will turn left
else if (state == 'L') {
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
Serial.println("Turn LEFT");
flag=1;
}
delay(1500);
state=3;
stateStop=1;
}
// if the state is 'S' the motor will Stop
else if (state == 'S' || stateStop == 1) {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
Serial.println("STOP!");
flag=1;
}
stateStop=0;
}
// if the state is 'R' the motor will turn right
else if (state == 'R') {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
if(flag == 0){
Serial.println("Turn RIGHT");
flag=1;
}
delay(1500);
state=3;
stateStop=1;
}
// if the state is 'B' the motor will Reverse
else if (state == 'B') {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
if(flag == 0){
Serial.println("Reverse!");
flag=1;
}
}
//For debugging purpose
//Serial.println(state);
}
// codes end here
After making these all we will connect 2 Small solar panels with the battery and connect the +ve terminal of the motor with a diode and then connect the diode with the +ve terminal of the battery and then connect the –ve terminal of the motor with the –ve terminal of battery.
You can also connect the solar panel and the motor working as wing generator by seeing the picture.
Step 3: Working: -
Let me show
you how the ultrasonic parking sensor works.
An ultrasonic sensor sends off a sound wave and then detects the return of the same sound wave. It uses the time travelled by the wave to calculate distance to the obstacle that reflected the wave, by this equation:
Distance (in cm) = Time (in µs) X 0.0034
Let me show you that how Bluetooth can be used to control the sustainable energy car.
We have used Bluetooth RC Controller.apk to control this car.
When we press any button on the app it sends a signal to the Bluetooth module (HC-05) and the Bluetooth module sends an electric signal to L293D motor IC which commands the motor to run.
For e.g.: - When we press forward button on the app both the motor moves in the forward direction.
Step 4: Etch
If you want to etch ultrasonic parking siren you can see the picture given to make a shield for ultrasonic parking siren.
Step 5: Please Vote
If you liked my instructable please vote for me in arduino contest please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
please vote for me because every vote counts.
Step 6: Thank You
So I thank you for watching my instructable and getting inspired from my instructable.
And please like www.facebook.com/diyprojectroombykartikverma
Also subscribe the channel https://www.youtube.com/channel/UCNxxBOktINZ35oAH-...