char a;
#define m1 7
#define m2 6
#define m3 5
#define m4 4
#define fl 8 //front lights
#define fl2 9
#define bl 10//back lights
#define bl2 11
void setup() {
pinMode(m1, OUTPUT);
pinMode(m2, OUTPUT);
pinMode(m3, OUTPUT);
pinMode(m4, OUTPUT);
pinMode(fl, OUTPUT);
pinMode(fl2, OUTPUT);
pinMode(bl, OUTPUT);
pinMode(bl2, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()){
a = Serial.read();
Serial.println(a);
}
if(a == 'F'){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
}
else if(a == 'B'){
digitalWrite(m2, HIGH);
digitalWrite(m1, LOW);
digitalWrite(m4, HIGH);
digitalWrite(m3, LOW);
}
else if(a == 'L'){
digitalWrite(m1, LOW);
digitalWrite(m2, LOW);
digitalWrite(m3, HIGH);
digitalWrite(m4, LOW);
}
else if(a == 'R'){
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
digitalWrite(m3, LOW);
digitalWrite(m4, LOW);
}
else if(a == 'W'){
digitalWrite(fl, HIGH);
digitalWrite(fl2, HIGH);
}
else if(a == 'w'){
digitalWrite(fl, LOW);
digitalWrite(fl2, LOW);
}
else if(a == 'U'){
digitalWrite(bl, HIGH);
digitalWrite(bl2, HIGH);
}
else if(a == 'u'){
digitalWrite(bl, LOW);
digitalWrite(bl2, LOW);
}
else{
digitalWrite(m1,LOW);
digitalWrite(m2,LOW);
digitalWrite(m3,LOW);
digitalWrite(m4,LOW);
}
delay(100);
}
Comments