Mobile Controlled Robot with Bluetooth
Control your Robots connected to Micro controllers like Arduino, 8051, PIC etc with this Application via Bluetooth Communication.
Arduino Example Code:
#include
SoftwareSerial mySerial(2, 3);
int motor1_pin1 = 5;
int motor1_pin2 = 7;
int motor2_pin1 = 9;
int motor2_pin2 = 11;
String voice;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(motor1_pin1,OUTPUT);
pinMode(motor1_pin2,OUTPUT);
pinMode(motor2_pin1,OUTPUT);
pinMode(motor2_pin2,OUTPUT);
}
void loop() {
serialEvent();
}
void Forward(){
digitalWrite(motor1_pin1,HIGH);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,HIGH);
digitalWrite(motor2_pin2,LOW);
Serial.println("Forward");
}
void Reverse(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,HIGH);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,HIGH);
Serial.println("Reverse");
}
void Left(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,HIGH);
digitalWrite(motor2_pin1,HIGH);
digitalWrite(motor2_pin2,LOW);
Serial.println("Left");
}
void Right(){
digitalWrite(motor1_pin1,HIGH);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,HIGH);
Serial.println("Right");
}
void Halt(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,LOW);
Serial.println("Halt");
}
void serialEvent() {
while (mySerial.available()){
delay(10);
char c = mySerial.read();
if (c == '#') {
break;
}
voice += c;
}
if (voice.length() > 0) {
if (voice == "forward" || voice == "A")
Forward();
else if (voice == "reverse" || voice == "B")
Reverse();
else if (voice == "left" || voice == "C")
Left();
else if (voice == "right" || voice == "D")
Right();
else if (voice == "stop" || voice == "E")
Halt();
voice="";
}
}
Control your Robots connected to Micro controllers like Arduino, 8051, PIC etc with this Application via Bluetooth Communication.
Arduino Example Code:
#include
SoftwareSerial mySerial(2, 3);
int motor1_pin1 = 5;
int motor1_pin2 = 7;
int motor2_pin1 = 9;
int motor2_pin2 = 11;
String voice;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(motor1_pin1,OUTPUT);
pinMode(motor1_pin2,OUTPUT);
pinMode(motor2_pin1,OUTPUT);
pinMode(motor2_pin2,OUTPUT);
}
void loop() {
serialEvent();
}
void Forward(){
digitalWrite(motor1_pin1,HIGH);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,HIGH);
digitalWrite(motor2_pin2,LOW);
Serial.println("Forward");
}
void Reverse(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,HIGH);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,HIGH);
Serial.println("Reverse");
}
void Left(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,HIGH);
digitalWrite(motor2_pin1,HIGH);
digitalWrite(motor2_pin2,LOW);
Serial.println("Left");
}
void Right(){
digitalWrite(motor1_pin1,HIGH);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,HIGH);
Serial.println("Right");
}
void Halt(){
digitalWrite(motor1_pin1,LOW);
digitalWrite(motor1_pin2,LOW);
digitalWrite(motor2_pin1,LOW);
digitalWrite(motor2_pin2,LOW);
Serial.println("Halt");
}
void serialEvent() {
while (mySerial.available()){
delay(10);
char c = mySerial.read();
if (c == '#') {
break;
}
voice += c;
}
if (voice.length() > 0) {
if (voice == "forward" || voice == "A")
Forward();
else if (voice == "reverse" || voice == "B")
Reverse();
else if (voice == "left" || voice == "C")
Left();
else if (voice == "right" || voice == "D")
Right();
else if (voice == "stop" || voice == "E")
Halt();
voice="";
}
}
Show More