Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Meu motor
- Vermelho IN1
- Laranja IN2
- Amarelo IN3
- Marron IN4
- */
- // UNO Leonardo
- #define IN1 8
- #define IN2 9
- #define IN3 10
- #define IN4 11
- /*
- // Mega
- #define IN1 22
- #define IN2 23
- #define IN3 24
- #define IN4 25
- */
- //------------------------------------
- void setup() {
- pinMode(IN1, OUTPUT);
- pinMode(IN2, OUTPUT);
- pinMode(IN3, OUTPUT);
- pinMode(IN4, OUTPUT);
- }
- //------------------------------------
- void loop()
- {
- cw();
- delay(1000);
- ccw();
- delay(1000);
- }
- //-------------------------------
- void cw()
- {
- digitalWrite(IN1, HIGH);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, LOW);
- delay(800);
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, HIGH);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, LOW);
- delay(800);
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, HIGH);
- digitalWrite(IN4, LOW);
- delay(800);
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, HIGH);
- delay(800);
- }
- //-------------------------------
- void ccw()
- {
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, HIGH);
- delay(800);
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, HIGH);
- digitalWrite(IN4, LOW);
- delay(800);
- digitalWrite(IN1, LOW);
- digitalWrite(IN2, HIGH);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, LOW);
- delay(800);
- digitalWrite(IN1, HIGH);
- digitalWrite(IN2, LOW);
- digitalWrite(IN3, LOW);
- digitalWrite(IN4, LOW);
- delay(800);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement