const int DriverA_1 = A0; const int DriverA_2 = A1; //const int DriverB_1 = 10; //const int DriverB_2 = 11; char key; char S = 's'; char B = 'b'; char C = 'c'; void setup() { pinMode(DriverA_1, OUTPUT); pinMode(DriverA_2, OUTPUT); //pinMode(DriverB_1, OUTPUT); //pinMode(DriverB_2, OUTPUT); Serial.begin(9600); } void loop() { if (Serial.available()) { key = Serial.read(); if(key == S){ Serial.print("Start!"); Serial.println(""); motor(HIGH, LOW, 3000); } else if (key == B){ Serial.print("Back!"); Serial.println(""); motor(LOW, HIGH, 3000); } else if (key == C){ Serial.print("Stop!"); Serial.println(""); motor(LOW, LOW, 3000); } } } void motor(int a1, int a2, int d){ digitalWrite(DriverA_1, a1); digitalWrite(DriverA_2, a2); //digitalWrite(DriverB_1, a1); //digitalWrite(DriverB_2, a2); delay(d); }