//L293D
//Motor A (left)
const int motorPin1 = 9; // Pin 2 of L293
const int motorPin2 = 10; // Pin 7 of L293
//Motor B (right)
const int motorPin3 = 11; // Pin 10 of L293
const int motorPin4 = 12; // Pin 15 of L293
#define TIME_WAIT 7200 //10sec
void setup() {
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void motor_a_stop() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
}
void motor_a_forward() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
}
void motor_a_backward() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
}
void motor_b_stop() {
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
}
void motor_b_forward() {
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}
void motor_b_backward() {
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, 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);
}