Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- If you motors turn the wrong way, switch the wires over
- Pin translation for using the Wemos with the Arduino IDE:
- *
- Wemos D1 mini Pin Number Arduino IDE Pin Number
- D0 16
- D1 5
- D2 4
- D3 0
- D4 2
- D5 14
- D6 12
- D7 13
- D8 15
- TX 1
- RX 3
- **/
- //Define Pins
- //Motor A
- int enableA = 0; //D3
- int MotorA1 = 4; //D2
- int MotorA2 = 5; //D1
- //Motor B
- int enableB = 16; //D0
- int MotorB1 = 14; //D5
- int MotorB2 = 2; //D4
- void setup() {
- //configure pin modes
- pinMode (enableA, OUTPUT);
- pinMode (MotorA1, OUTPUT);
- pinMode (MotorA2, OUTPUT);
- pinMode (enableB, OUTPUT);
- pinMode (MotorB1, OUTPUT);
- pinMode (MotorB2, OUTPUT);
- }
- void loop() {
- //Enable motors
- digitalWrite (enableA, HIGH);
- digitalWrite (enableB, HIGH);
- delay (1000);
- //Go forward for 1 second
- digitalWrite (MotorA1, LOW);
- digitalWrite (MotorA2, HIGH);
- digitalWrite (MotorB1, LOW);
- digitalWrite (MotorB2, HIGH);
- delay (1000);
- //Go backwards for 2 seconds
- digitalWrite (MotorA1,HIGH);
- digitalWrite (MotorA2,LOW);
- digitalWrite (MotorB1,HIGH);
- digitalWrite (MotorB2,LOW);
- delay (2000);
- //Stop all motors then stop for 5 seconds
- digitalWrite (enableA, LOW);
- digitalWrite (enableB, LOW);
- delay (5000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement