int motor1 = 8;
int motor2 = 9;
void setup() {
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int inByte = Serial.read();
Serial.println(inByte);
if (inByte == 1) {
digitalWrite(motor1, LOW);
digitalWrite(motor2, LOW);
} else if (inByte == 2) {
digitalWrite(motor1, HIGH);
digitalWrite(motor2, HIGH);
delay(5000);
digitalWrite(motor1, LOW);
digitalWrite(motor2, LOW);
} else {
digitalWrite(motor1, LOW);
digitalWrite(motor2, LOW);
}
// Wait for 1 second
delay(100);
}
}