//String mode = "drivebeepdrive";
String mode = "remote";
boolean blink = false;

void setup()
{
  Serial.begin(9600);

  pinMode(12, OUTPUT); //motor1
  pinMode(13, OUTPUT); //motor2
  pinMode( 9, OUTPUT); //speaker
  pinMode( 8, OUTPUT); //LEDs
  pinMode( 2, OUTPUT); //test
}

void loop()
{
  if(mode == "drivebeepdrive"){
    digitalWrite(12, HIGH);
    digitalWrite(13, HIGH);
    delay(3000);
    for(int i = 0; i <=3; i++){
      digitalWrite(8, HIGH);
     // digitalWrite(9, HIGH);
      delay(300);
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
      Serial.println("test");
      delay(300);
    }
    delay(3000);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    delay(5000);
  }
  
  
  if(mode == "driveledblink"){
    digitalWrite(9, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, HIGH);
    digitalWrite(8, HIGH);
    delay(500);
    digitalWrite(8, LOW);
    delay(300);
  }
  
  if(mode == "remote"){
    if (Serial.available()){
      swith(Serial.read()){
        case 'w':     digitalWrite(12, HIGH);
                      digitalWrite(13, HIGH); break;
        case 'a':     digitalWrite(12,  LOW);
                      digitalWrite(13, HIGH); break;
        case 'd':     digitalWrite(12, HIGH);
                      digitalWrite(13,  LOW); break;
        case 'b':     blink = !blink;
        default:      digitalWrite(12, LOW);
                      digitalWrite(13, LOW);        
      }
      if(blink){
        digitalWrite(8, HIGH);
        delay(500);
        digitalWrite(8, LOW);
        delay(500);
      }
    }
  }
}


