Advertisement
GUPPYYYY

motors

Sep 25th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. const int In1 = 9;
  2.  
  3. const int In2 = 8;
  4.  
  5. const int In3 = 10;
  6.  
  7. const int In4 = 11;
  8.  
  9.  
  10.  
  11.  
  12. void setup()
  13.  
  14. {
  15.  
  16. // All motor control pins are outputs
  17.  
  18. pinMode(In1, OUTPUT);
  19. pinMode(In2, OUTPUT);
  20. pinMode(In3, OUTPUT);
  21. pinMode(In4, OUTPUT);
  22.  
  23.  
  24.  
  25. }
  26.  
  27. void goStraight() //run both motors in the same direction
  28.  
  29. {
  30.  
  31. // turn on motor A
  32.  
  33. digitalWrite(In1, HIGH);
  34. digitalWrite(In2, LOW);
  35. digitalWrite(In3, HIGH);
  36. digitalWrite(In4, LOW);
  37.  
  38.  
  39. delay(2000);
  40.  
  41. // now turn off motors
  42.  
  43. digitalWrite(In1, LOW);
  44. digitalWrite(In2, LOW);
  45. digitalWrite(In3, LOW);
  46. digitalWrite(In4, LOW);
  47.  
  48. }
  49. void loop()
  50. {
  51. goStraight();
  52.  
  53. delay(1000);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement