实验开源代码
- /*
- 【花雕动手做】太搞笑啦,用一支密封胶管制成二只空心轮蠕动机器人
- 实验程序:前后与左转、右转各二秒钟
- */
-
- void setup() {
- pinMode(9, OUTPUT);
- pinMode(10, OUTPUT);
- pinMode(11, OUTPUT);
- pinMode(12, OUTPUT);
- }
-
- void loop() {
- digitalWrite(9, HIGH); //向前二秒
- digitalWrite(10, LOW);
- digitalWrite(11, HIGH);
- digitalWrite(12, LOW);
- delay(2000);
-
- digitalWrite(9, LOW); //停止一秒
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- delay(1000);
-
- digitalWrite(9, LOW); //向后二秒
- digitalWrite(10, HIGH);
- digitalWrite(11, LOW);
- digitalWrite(12, HIGH);
- delay(2000);
-
- digitalWrite(9, LOW); //停止一秒
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- delay(1000);
-
- digitalWrite(9, HIGH); //左转二秒
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, HIGH);
- delay(2000);
-
- digitalWrite(9, LOW); //停止一秒
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- delay(1000);
-
- digitalWrite(9, LOW); //右转二秒
- digitalWrite(10, HIGH);
- digitalWrite(11, HIGH);
- digitalWrite(12, LOW);
- delay(2000);
-
- digitalWrite(9, LOW); //停止一秒
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- delay(1000);
- }
复制代码
|