Arduino pro mini
HC-06 Serial bluetooth slave module ( password: 1234)
L293D motor driver
5v Electronic Buzzer
9V Rechargeable Battery
9V to DC Barrel Adapter
DC Barrel Dişi Power Jack
Pertinax Board
Arduino Code
char blueToothVal; //value sent over via bluetooth
//char lastValue; //stores last state of device (on/off)
int motor1Pin1 = 12;
int motor1Pin2 = 11;
int motor2Pin1 = 10;
int motor2Pin2 = 9;
char a,b,c,d,e,f,g,h,s;
void setup() {
Serial.begin(9600);
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
}
void loop() {
if(Serial.available()>0)
{//if there is data being recieved
blueToothVal=Serial.read(); //read it
Serial.print(blueToothVal);
} // put your main code here, to run repeatedly:
if (blueToothVal=='a'){
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
}
if (blueToothVal=='b'){
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
}
if (blueToothVal=='c'){
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
}
if (blueToothVal=='d'){
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
}
if (blueToothVal=='e'){ //ileri sag
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
}
if (blueToothVal=='f'){ //ileri sol
digitalWrite(motor1Pin1, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
}
if (blueToothVal=='g'){ //geri sag
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
}
if (blueToothVal=='h'){ //geri sol
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
}
if (blueToothVal=='s'){ //dur
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
}
delay(10);
}
Post a Comment