#define LM 9 #define RM 10 int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor int thirdSensor = 0; // digital sensor int inByte = 0; // incoming serial byte char BYTE; boolean status_unlock; boolean status_bluetooth; long interval = 1000; // interval at which to blink (milliseconds) long previousMillis = 0; // will store last time LED was update int minite,sec; void setup() { // start serial port at 9600 bps: Serial.begin(9600); establishContact(); // send a byte to establish contact until receiver responds pinMode(LM, OUTPUT); pinMode(RM, OUTPUT); digitalWrite(LM, LOW); // switch off MOTOR digitalWrite(RM, LOW); // switch off MOTOR status_bluetooth = true; status_unlock = false; sec = 0; } void loop() { if (Serial.available() > 0) { inByte = Serial.read(); // get incoming byte: if(inByte == 'A') { analogWrite(LM,190); analogWrite(RM,160); inByte = 0; } if(inByte == 'B') { analogWrite(LM,190); analogWrite(RM,190); inByte = 0; } if(inByte == 'C') { analogWrite(LM,160); analogWrite(RM,190); inByte = 0; } if(inByte == 'D') { analogWrite(LM,160); analogWrite(RM,130); inByte = 0; } if(inByte == 'E') { analogWrite(LM,160); analogWrite(RM,160); inByte = 0; } if(inByte == 'F') { analogWrite(LM,130); analogWrite(RM,160); inByte = 0; } if(inByte == 'G') { analogWrite(LM,130); analogWrite(RM,100); inByte = 0; } if(inByte == 'H') { analogWrite(LM,100); analogWrite(RM,100); inByte = 0; } if(inByte == 'I') { analogWrite(LM,100); analogWrite(RM,130); inByte = 0; } if(inByte == 'J') { analogWrite(LM,100); analogWrite(RM,0); inByte = 0; } if(inByte == 'K') { analogWrite(LM,0); analogWrite(RM,0); inByte = 0; } if(inByte == 'L') { analogWrite(LM,0); analogWrite(RM,100); inByte = 0; } if(inByte == 'S') { Serial.print('S', BYTE); // send a char status_bluetooth = true; sec = 0; } } // if(Serial } //Loop void establishContact() { while (Serial.available() <= 0) { Serial.print('.', BYTE); // send a capital A delay(500); } }