Arduino Bluetooth Car Code

                                                 

  //***************************Written by Simple Circuits*****************************//

 

  char t;

void setup() {

pinMode(13,OUTPUT);   //left motors forward

pinMode(12,OUTPUT);   //left motors reverse

pinMode(11,OUTPUT);   //right motors forward

pinMode(10,OUTPUT);   //right motors reverse

pinMode(9,OUTPUT);    //Front Led

pinMode(8,OUTPUT);    //Back led

pinMode(7,OUTPUT);    //Reverse Parking led

pinMode(6,OUTPUT);    //Buzzer

Serial.begin(9600); 

}

 

void loop() {

if(Serial.available()){

  t = Serial.read();

  Serial.println(t);

}

 

if(t == 'F'){            //move forward(all motors rotate in forward direction)

  digitalWrite(13,HIGH);

  digitalWrite(11,HIGH);

}

 

else if(t == 'B'){      //move reverse (all motors rotate in reverse direction)

  digitalWrite(12,HIGH);

  digitalWrite(10,HIGH);

}

 

else if(t == 'L'){      //turn right (left side motors rotate in forward direction, right side motors doesn't rotate)

  digitalWrite(11,HIGH);

}

 

else if(t == 'R'){      //turn left (right side motors rotate in forward direction, left side motors doesn't rotate)

  digitalWrite(13,HIGH);

}


else if(t == 'W'){    //turn led on or off front)

  digitalWrite(9,HIGH);

}

else if(t == 'w'){

  digitalWrite(9,LOW);

}

else if(t == 'U'){    //turn led on or off back)

  digitalWrite(8,HIGH);

}

else if(t == 'u'){

  digitalWrite(8,LOW);

}

else if(t == 'X'){    //turn led on or off parking)

  digitalWrite(7,HIGH);

}

else if(t == 'x'){

  digitalWrite(7,LOW);

}

else if(t == 'V'){    //turn led on or off buzzer)

  digitalWrite(6,HIGH); 

}

else if(t == 'v'){

  digitalWrite(6,LOW);

}

 

else if(t == 'S'){      //STOP (all motors stop)

  digitalWrite(13,LOW);

  digitalWrite(12,LOW);

  digitalWrite(11,LOW);

  digitalWrite(10,LOW);

}

}

Comments

Popular posts from this blog

Arduino Code Car Parking System

Arduino Code