Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SparkFun_TB6612.h>
- Motor motorRight = Motor(2,3,5,-1,12); // In1A In2A PWMA Offset Standby
- Motor motorLeft = Motor(8,9,10,-1,12); // In1b In2B PWMB Offset Standby
- //(1,1) (3,4) (6,6)Introduction example on cartesian graph (coordinates)
- int y0 = 0;
- int x0 = 0;
- int x1 = 1;
- int y1 = 1;
- int x2 = 3;
- int y2 = 4;
- int x3 = 6;
- int y3 = 6;
- int motorDuration = 900;
- int motorPower = 100;
- int rotDurationLeft = 1275;
- int rotDurationRight = 1240;
- void setup() {
- // put your setup code here, to run once:
- forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
- delay(motorDuration * x1 + x0); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
- delay(rotDurationLeft);
- brake(motorLeft, motorRight);
- forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
- delay(200 * y2 - y1); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- right(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
- delay(rotDurationRight);
- brake(motorLeft, motorRight);
- forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
- delay(525 * x2 - x1); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
- delay(rotDurationLeft);
- brake(motorLeft, motorRight);
- forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
- delay(550 * y2 - y1); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- right(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
- delay(rotDurationRight);
- brake(motorLeft, motorRight);
- forward(motorLeft,motorRight,motorPower+30); // Enables both motors set at a certain rate (100)
- delay(550 * x2 - x1); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- left(motorLeft,motorRight,motorPower); // Turns motors in opposite direction to the left.
- delay(rotDurationLeft);
- brake(motorLeft, motorRight);
- forward(motorLeft,motorRight,motorPower); // Enables both motors set at a certain rate (100)
- delay(525 * y2 - y1); // Leaves motors on for a certain period of time
- brake(motorLeft, motorRight);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement