//L293D
//Motor A
const int motorPin1 = 9; // Pin 14 of L293
const int motorPin2 = 10; // Pin 10 of L293
//Motor B
const int motorPin3 = 12; // Pin 7 of L293
const int motorPin4 = 11; // Pin 2 of L293
#define TIME_WAIT 15000
void setup() {
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void left_stop() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
}
void right_stop() {
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
}
void stop() {
left_stop();
right_stop();
}
void left_forward() {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
}
void left_backward() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
}
void right_forward() {
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
}
void right_backward() {
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}
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(2000);
}