YouNeed:-
HC-06 Bluetooth Module
BREAD BOARD
Geared Motor
TYRES
ARDUINO UNO
6V Battery
L293D Motor Controller IC
CIRCUIT
This is tested and 100% working
CODE
#include <Servo.h>
int r_mtr_n = 2; // assign motor pins to arduino
int r_mtr_p = 4;
int l_mtr_p = 5;
int l_mtr_n = 7;
int ledPin=13;
int Sensor_pin = 3;
int Buzzerpin = 9;
int incomingByte = 0; // assign pin for bluetooth module
void Alarm()
{
digitalWrite(Buzzerpin,HIGH);
digitalWrite(ledPin,HIGH);
delay(5);
digitalWrite(Buzzerpin,LOW);
digitalWrite(ledPin,LOW);
}
void setup()
{
pinMode(r_mtr_n, OUTPUT);
pinMode(r_mtr_p, OUTPUT);
pinMode(l_mtr_p, OUTPUT);
pinMode(l_mtr_n, OUTPUT);
pinMode(ledPin,OUTPUT);
pinMode(Sensor_pin,INPUT);
pinMode(Buzzerpin,OUTPUT);
digitalWrite(r_mtr_n, LOW);
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
int val=digitalRead(Sensor_pin);
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else{
if (Serial.available() > 0)
{
incomingByte = Serial.read();
}
switch(incomingByte)
{
case 'S':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
}
break;
case 'R':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, HIGH); // control for right
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("Right");
incomingByte='*';
}
break;
case 'L':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for left
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("Left");
incomingByte='*';
}
break;
case 'F':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, HIGH); // control for forward
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("Forward");
incomingByte='*';
}
break;
case 'B':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for backward
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("Backword");
incomingByte='*';
}
break;
}
}
}
Download bluetooth controlled fro here
For video click here
HC-06 Bluetooth Module
BREAD BOARD
Geared Motor
TYRES
ARDUINO UNO
6V Battery
L293D Motor Controller IC
CIRCUIT
This is tested and 100% working
CODE
#include <Servo.h>
int r_mtr_n = 2; // assign motor pins to arduino
int r_mtr_p = 4;
int l_mtr_p = 5;
int l_mtr_n = 7;
int ledPin=13;
int Sensor_pin = 3;
int Buzzerpin = 9;
int incomingByte = 0; // assign pin for bluetooth module
void Alarm()
{
digitalWrite(Buzzerpin,HIGH);
digitalWrite(ledPin,HIGH);
delay(5);
digitalWrite(Buzzerpin,LOW);
digitalWrite(ledPin,LOW);
}
void setup()
{
pinMode(r_mtr_n, OUTPUT);
pinMode(r_mtr_p, OUTPUT);
pinMode(l_mtr_p, OUTPUT);
pinMode(l_mtr_n, OUTPUT);
pinMode(ledPin,OUTPUT);
pinMode(Sensor_pin,INPUT);
pinMode(Buzzerpin,OUTPUT);
digitalWrite(r_mtr_n, LOW);
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
int val=digitalRead(Sensor_pin);
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else{
if (Serial.available() > 0)
{
incomingByte = Serial.read();
}
switch(incomingByte)
{
case 'S':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
}
break;
case 'R':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, HIGH); // control for right
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("Right");
incomingByte='*';
}
break;
case 'L':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Detected\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for left
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("Left");
incomingByte='*';
}
break;
case 'F':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, HIGH); // control for forward
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("Forward");
incomingByte='*';
}
break;
case 'B':
if(val == 1)
{
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
Alarm();
}
else
{
digitalWrite(r_mtr_n, LOW); // control for backward
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("Backword");
incomingByte='*';
}
break;
}
}
}
Download bluetooth controlled fro here
For video click here