Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. #include <SparkFun_TB6612.h>
  2.  
  3. Motor motorRight = Motor(2,3,5,-1,12); // In1A In2A PWMA Offset Standby
  4. Motor motorLeft = Motor(8,9,10,-1,12); // In1b In2B PWMB Offset Standby
  5.  
  6. //(1,1) (3,4) (6,6)Introduction example on cartesian graph (coordinates)
  7. int y0 = 0;
  8. int x0 = 0;
  9. int x1 = 1;
  10. int y1 = 1;
  11. int x2 = 3;
  12. int y2 = 4;
  13. int x3 = 6;
  14. int y3 = 6;
  15.  
  16. int motorDuration = 900;
  17. int motorPower = 100;
  18. int rotDurationLeft = 1275;
  19. int rotDurationRight = 1240;
  20. void setup() {
  21. // put your setup code here, to run once:
  22. forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
  23. delay(motorDuration * x1 + x0); // Leaves motors on for a certain period of time
  24. brake(motorLeft, motorRight);
  25.  
  26. left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
  27. delay(rotDurationLeft);
  28. brake(motorLeft, motorRight);
  29.  
  30. forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
  31. delay(200 * y2 - y1); // Leaves motors on for a certain period of time
  32. brake(motorLeft, motorRight);
  33.  
  34. right(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
  35. delay(rotDurationRight);
  36. brake(motorLeft, motorRight);
  37.  
  38. forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
  39. delay(525 * x2 - x1); // Leaves motors on for a certain period of time
  40. brake(motorLeft, motorRight);
  41.  
  42. left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
  43. delay(rotDurationLeft);
  44. brake(motorLeft, motorRight);
  45.  
  46. forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
  47. delay(550 * y2 - y1); // Leaves motors on for a certain period of time
  48. brake(motorLeft, motorRight);
  49.  
  50.  
  51. right(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
  52. delay(rotDurationRight);
  53. brake(motorLeft, motorRight);
  54.  
  55. forward(motorLeft,motorRight,motorPower+30); // Enables both motors set at a certain rate (100)
  56. delay(550 * x2 - x1); // Leaves motors on for a certain period of time
  57. brake(motorLeft, motorRight);
  58.  
  59. left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
  60. delay(rotDurationLeft);
  61. brake(motorLeft, motorRight);
  62.  
  63. forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
  64. delay(525 * y2 - y1); // Leaves motors on for a certain period of time
  65. brake(motorLeft, motorRight);
  66.  
  67.  
  68. }
  69.  
  70. void loop() {
  71. // put your main code here, to run repeatedly:
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement