int point_id2 = 2; int point_id3 = 3; int point_id4 = 4; int point_id5 = 5; int point_id8 = 8; int point_id9 = 9; int point_id10 = 10; int point_id11 = 11; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(point_id4,OUTPUT); pinMode(point_id5,OUTPUT); digitalWrite(point_id4,LOW); digitalWrite(point_id5,HIGH); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()){ char r_data = Serial.read(); //A 停止后退 if(r_data=='A'){ digitalWrite(point_id4,LOW); digitalWrite(point_id5,LOW); } //B 后退 if(r_data=='B'){ digitalWrite(point_id4,HIGH); digitalWrite(point_id5,HIGH); } //C 后退 if(r_data=='C'){ digitalWrite(point_id4,LOW); digitalWrite(point_id5,HIGH); } //D 后退 if(r_data=='D'){ digitalWrite(point_id4,HIGH); digitalWrite(point_id5,LOW); } } }
##################
标签:控制,id5,point,int,digitalWrite,id4,电机,LOW,arduino From: https://www.cnblogs.com/herd/p/17500146.html