safwan092

Blue Motor Driver Simple Code

Mar 1st, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <AFMotor.h>
  2.  
  3. AF_DCMotor motor1(1);
  4. AF_DCMotor motor2(2);
  5.  
  6. void setup() {
  7. motor1.setSpeed(255);
  8. motor2.setSpeed(255);
  9. motor1.run(RELEASE);
  10. motor2.run(RELEASE);
  11.  
  12. }
  13.  
  14. void loop() {
  15. FRONT();
  16. delay(2000);
  17. BACKWARDS();
  18. delay(2000);
  19. LEFT();
  20. delay(2000);
  21. RIGHT();
  22. delay(2000);
  23. }
  24.  
  25.  
  26. void FRONT() {
  27. motor1.run(FORWARD);
  28. motor2.run(FORWARD);
  29. }
  30.  
  31. void BACKWARDS() {
  32. motor1.run(BACKWARD);
  33. motor2.run(BACKWARD);
  34. }
  35.  
  36. void LEFT() {
  37. motor1.run(FORWARD);
  38. motor2.run(BACKWARD);
  39. }
  40.  
  41. void RIGHT() {
  42. motor1.run(BACKWARD);
  43. motor2.run(FORWARD);
  44. }
  45.  
  46. void STOPP() {
  47. motor1.run(RELEASE);
  48. motor2.run(RELEASE);
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment