Advertisement
Erfinator

Rover motor test

Dec 20th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1.  
  2. const int Motor1Pin1 = 3;
  3. const int Motor1Pin2 = 4;
  4. const int Motor2Pin1 = 5;
  5. const int Motor2Pin2 = 6;
  6.  
  7. void setup() {
  8. pinMode(Motor1Pin1, OUTPUT);
  9. pinMode(Motor1Pin2, OUTPUT);
  10. pinMode(Motor2Pin1, OUTPUT);
  11. pinMode(Motor2Pin2, OUTPUT);
  12. }
  13.  
  14.  
  15. void loop() {
  16. GoForward();
  17. delay(1000);
  18. GoBackward();
  19. delay(1000);
  20. GoRight();
  21. delay(1000);
  22. GoLeft();
  23. delay(1000);
  24. Stop();
  25. delay(1000);
  26. }
  27.  
  28. void GoForward(){
  29. digitalWrite(Motor1Pin2, LOW);
  30. digitalWrite(Motor1Pin1, HIGH);
  31. digitalWrite(Motor2Pin2, LOW);
  32. digitalWrite(Motor2Pin1, HIGH);
  33. }
  34.  
  35. void GoBackward(){
  36. digitalWrite(Motor1Pin1, LOW);
  37. digitalWrite(Motor1Pin2, HIGH);
  38. digitalWrite(Motor2Pin1, LOW);
  39. digitalWrite(Motor2Pin2, HIGH);
  40. }
  41.  
  42. void GoLeft(){
  43. digitalWrite(Motor1Pin1, LOW);
  44. digitalWrite(Motor1Pin2, HIGH);
  45. digitalWrite(Motor2Pin2, LOW);
  46. digitalWrite(Motor2Pin1, HIGH);
  47. }
  48.  
  49. void GoRight(){
  50. digitalWrite(Motor1Pin2, LOW);
  51. digitalWrite(Motor1Pin1, HIGH);
  52. digitalWrite(Motor2Pin1, LOW);
  53. digitalWrite(Motor2Pin2, HIGH);
  54. }
  55.  
  56. void Stop(){
  57. digitalWrite(Motor1Pin2, LOW);
  58. digitalWrite(Motor1Pin1, LOW);
  59. digitalWrite(Motor2Pin1, LOW);
  60. digitalWrite(Motor2Pin2, LOW);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement