Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. void setup(){
  2.  
  3. //Set pins as outputs
  4. pinMode(motorPin1, OUTPUT);
  5. pinMode(motorPin2, OUTPUT);
  6. pinMode(motorPin3, OUTPUT);
  7. pinMode(motorPin4, OUTPUT);
  8.  
  9. //Motor Control - Motor A: motorPin1,motorpin2 & Motor B: motorpin3,motorpin4
  10.  
  11. //This code will turn Motor A clockwise for 2 sec.
  12. digitalWrite(motorPin1, HIGH);
  13. digitalWrite(motorPin2, LOW);
  14. digitalWrite(motorPin3, LOW);
  15. digitalWrite(motorPin4, LOW);
  16. delay(2000);
  17. //This code will turn Motor A counter-clockwise for 2 sec.
  18. digitalWrite(motorPin1, LOW);
  19. digitalWrite(motorPin2, HIGH);
  20. digitalWrite(motorPin3, LOW);
  21. digitalWrite(motorPin4, LOW);
  22. delay(2000);
  23.  
  24. //This code will turn Motor B clockwise for 2 sec.
  25. digitalWrite(motorPin1, LOW);
  26. digitalWrite(motorPin2, LOW);
  27. digitalWrite(motorPin3, HIGH);
  28. digitalWrite(motorPin4, LOW);
  29. delay(2000);
  30. //This code will turn Motor B counter-clockwise for 2 sec.
  31. digitalWrite(motorPin1, LOW);
  32. digitalWrite(motorPin2, LOW);
  33. digitalWrite(motorPin3, LOW);
  34. digitalWrite(motorPin4, HIGH);
  35. delay(2000);
  36.  
  37. //And this code will stop motors
  38. digitalWrite(motorPin1, LOW);
  39. digitalWrite(motorPin2, LOW);
  40. digitalWrite(motorPin3, LOW);
  41. digitalWrite(motorPin4, LOW);
  42. Serial.begin(9600);
  43.  
  44. }
  45.  
  46.  
  47. void loop()
  48. {
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement