Advertisement
RuiViana

TestaStep.ino

Feb 4th, 2019
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. /*
  2.    Meu motor
  3.    Vermelho IN1
  4.    Laranja  IN2
  5.    Amarelo  IN3
  6.    Marron   IN4
  7. */
  8. // UNO Leonardo
  9. #define IN1 8
  10. #define IN2 9
  11. #define IN3 10
  12. #define IN4 11
  13. /*
  14.   // Mega
  15.   #define IN1 22
  16.   #define IN2 23
  17.   #define IN3 24
  18.   #define IN4 25
  19. */
  20. //------------------------------------
  21. void setup() {
  22.   pinMode(IN1, OUTPUT);
  23.   pinMode(IN2, OUTPUT);
  24.   pinMode(IN3, OUTPUT);
  25.   pinMode(IN4, OUTPUT);
  26. }
  27.  //------------------------------------
  28. void loop()
  29. {
  30.  cw();
  31.  delay(1000);
  32.  ccw();
  33.  delay(1000);
  34. }
  35. //-------------------------------
  36. void cw()
  37. {
  38.   digitalWrite(IN1, HIGH);
  39.   digitalWrite(IN2, LOW);
  40.   digitalWrite(IN3, LOW);
  41.   digitalWrite(IN4, LOW);
  42.   delay(800);
  43.  
  44.   digitalWrite(IN1, LOW);
  45.   digitalWrite(IN2, HIGH);
  46.   digitalWrite(IN3, LOW);
  47.   digitalWrite(IN4, LOW);
  48.   delay(800);
  49.  
  50.   digitalWrite(IN1, LOW);
  51.   digitalWrite(IN2, LOW);
  52.   digitalWrite(IN3, HIGH);
  53.   digitalWrite(IN4, LOW);
  54.   delay(800);
  55.  
  56.   digitalWrite(IN1, LOW);
  57.   digitalWrite(IN2, LOW);
  58.   digitalWrite(IN3, LOW);
  59.   digitalWrite(IN4, HIGH);
  60.   delay(800);
  61. }
  62. //-------------------------------
  63. void ccw()
  64. {
  65.   digitalWrite(IN1, LOW);
  66.   digitalWrite(IN2, LOW);
  67.   digitalWrite(IN3, LOW);
  68.   digitalWrite(IN4, HIGH);
  69.   delay(800);
  70.  
  71.   digitalWrite(IN1, LOW);
  72.   digitalWrite(IN2, LOW);
  73.   digitalWrite(IN3, HIGH);
  74.   digitalWrite(IN4, LOW);
  75.   delay(800);
  76.  
  77.   digitalWrite(IN1, LOW);
  78.   digitalWrite(IN2, HIGH);
  79.   digitalWrite(IN3, LOW);
  80.   digitalWrite(IN4, LOW);
  81.   delay(800);
  82.  
  83.   digitalWrite(IN1, HIGH);
  84.   digitalWrite(IN2, LOW);
  85.   digitalWrite(IN3, LOW);
  86.   digitalWrite(IN4, LOW);
  87.   delay(800);
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement