#include <AFMotor.h>
AF_DCMotor rMotor(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor lMotor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor liftMotor(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
void setup() {
Serial.begin(9600);
}
void loop() {
forward();
delay(1000);
reverse();
delay(1000);
tRight();
delay(1000);
tLeft();
delay(1000);
stopBot();
delay(1000);
lUp();
delay(3000);
lDown();
delay(1000);
stopBot();
delay(1000);
while(true);
}
void forward(){
rMotor.setSpeed(255);
lMotor.setSpeed(255);
rMotor.run(FORWARD); // turn it on going forward
lMotor.run(FORWARD); // turn it on going forward
}
void reverse(){
rMotor.setSpeed(255);
lMotor.setSpeed(255);
rMotor.run(BACKWARD); // turn it on going forward
lMotor.run(BACKWARD); // turn it on going forward
}
void tLeft(){ //Turn Right
rMotor.setSpeed(255);
lMotor.setSpeed(255);
rMotor.run(FORWARD); // turn it on going forward
lMotor.run(BACKWARD); // turn it on going forward
}
void tRight(){ //Turn Right
rMotor.setSpeed(255);
lMotor.setSpeed(255);
rMotor.run(BACKWARD); // turn it on going forward
lMotor.run(FORWARD); // turn it on going forward
}
void stopBot(){ //Turn Right
rMotor.run(RELEASE); // Stop Motor
lMotor.run(RELEASE); // Stop Motor
liftMotor.run(RELEASE); // Stop Motor
}
void lUp(){ // Lift Upish
liftMotor.setSpeed(255);
liftMotor.run(FORWARD); // turn it on going forward
}
void lDown(){ // Lift Downish
liftMotor.setSpeed(255);
liftMotor.run(BACKWARD); // turn it on going forward
}