#define Dong1 D6 #define Dong2 D7 #define Zhuan1 D4 #define Zhuan2 D5 void initL9110s() { pinMode(Dong1,OUTPUT); pinMode(Dong2,OUTPUT); pinMode(Zhuan1,OUTPUT); pinMode(Zhuan2,OUTPUT); } void hou() { digitalWrite(Dong1,LOW); digitalWrite(Dong2,HIGH); } void qian() { digitalWrite(Dong1,HIGH); digitalWrite(Dong2,LOW); } void zuo() { digitalWrite(Zhuan1,HIGH); digitalWrite(Zhuan2,LOW); } void you() { digitalWrite(Zhuan1,LOW); digitalWrite(Zhuan2,HIGH); } void setup() { // put your setup code here, to run once: initL9110s(); Serial.begin(115200); } void loop() { // put your main code here, to run repeatedly: char cmd; if (Serial.available()>0) { cmd = Serial.read(); switch(cmd) { case 'q': qian(); break; case 'h': hou(); break; case 'z': zuo(); break; case 'y': you(); break; } } }