//L293D
//Motor A (left)
#define MOTOR_PIN1 9
#define MOTOR_PIN2 10
//Motor B (right)
#define MOTOR_PIN3 11
#define MOTOR_PIN4 12
#define TIME_WAIT 7200 //10sec
void setup() {
//Set pins as outputs
pinMode(MOTOR_PIN1, OUTPUT);
pinMode(MOTOR_PIN2, OUTPUT);
pinMode(MOTOR_PIN3, OUTPUT);
pinMode(MOTOR_PIN4, OUTPUT);
}
void motor_a_stop() {
digitalWrite(MOTOR_PIN1, LOW);
digitalWrite(MOTOR_PIN2, LOW);
}
void motor_a_forward() {
digitalWrite(MOTOR_PIN1, LOW);
digitalWrite(MOTOR_PIN2, HIGH);
}
void motor_a_backward() {
digitalWrite(MOTOR_PIN1, HIGH);
digitalWrite(MOTOR_PIN2, LOW);
}
void motor_b_stop() {
digitalWrite(MOTOR_PIN3, LOW);
digitalWrite(MOTOR_PIN4, LOW);
}
void motor_b_forward() {
digitalWrite(MOTOR_PIN3, LOW);
digitalWrite(MOTOR_PIN4, HIGH);
}
void motor_b_backward() {
digitalWrite(MOTOR_PIN3, HIGH);
digitalWrite(MOTOR_PIN4, LOW);
}
void left_stop() {
motor_a_stop();
}
void right_stop() {
motor_b_stop();
}
void stop() {
left_stop();
right_stop();
}
void left_forward() {
motor_a_backward();
}
void left_backward() {
motor_a_forward();
}
void right_forward() {
motor_b_forward();
}
void right_backward() {
motor_b_backward();
}
void forward() {
left_forward();
right_forward();
}
void backward() {
left_backward();
right_backward();
}
void left_rotate() {
left_backward();
right_forward();
}
void right_rotate() {
left_forward();
right_backward();
}
void left_circle() {
left_stop();
right_forward();
}
void right_circle() {
right_stop();
left_forward();
}
void wait() {
delay(TIME_WAIT);
stop();
}
void loop() {
forward();
wait();
backward();
wait();
left_rotate();
wait();
right_rotate();
wait();
left_circle();
wait();
right_circle();
wait();
stop();
delay(1800);
}