- /*
- 【花雕动手做】超低成本,尝试做个五十元的麦克纳姆轮小车!
-
- 实验接线方法:
- MX1508模块 Ardunio Uno
- GND---------GND接地线
- VCC---------5V 接电源
- IN1---------D6
- IN2 ------- D7
- IN3---------D8
- IN4 ------- D9
- IN1---------D10
- IN2 ------- D11
- IN3---------D12
- IN4 ------- D13
-
- 程序之一:简易控制麦轮小车前进与后退
- 电机正转3秒,停止1秒,反转3秒,停止1秒,循环
- */
-
- void setup() {
- pinMode(6, OUTPUT);
- pinMode(7, OUTPUT);
- pinMode(8, OUTPUT);
- pinMode(9, OUTPUT);
- pinMode(10, OUTPUT);
- pinMode(11, OUTPUT);
- pinMode(12, OUTPUT);
- pinMode(13, OUTPUT);
- }
-
- void loop() {
- digitalWrite(6, HIGH);
- digitalWrite(7, LOW);
- digitalWrite(8, HIGH);
- digitalWrite(9, LOW);
- digitalWrite(10, HIGH);
- digitalWrite(11, LOW);
- digitalWrite(12, HIGH);
- digitalWrite(13, LOW);
- delay(3000);
-
- digitalWrite(6, LOW);
- digitalWrite(7, LOW);
- digitalWrite(8, LOW);
- digitalWrite(9, LOW);
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- digitalWrite(13, LOW);
- delay(1000);
-
- digitalWrite(6, LOW);
- digitalWrite(7, HIGH);
- digitalWrite(8, LOW);
- digitalWrite(9, HIGH);
- digitalWrite(10, LOW);
- digitalWrite(11, HIGH);
- digitalWrite(12, LOW);
- digitalWrite(13, HIGH);
- delay(3000);
-
- digitalWrite(6, LOW);
- digitalWrite(7, LOW);
- digitalWrite(8, LOW);
- digitalWrite(9, LOW);
- digitalWrite(10, LOW);
- digitalWrite(11, LOW);
- digitalWrite(12, LOW);
- digitalWrite(13, LOW);
- delay(1000);
- }
复制代码
|