//Motor
const int motorPin1 = 9; // Pin
const int motorPin2 = 10; // Pin
//Motor
const int motorPin3 =
const int motorPin4 =
#define TIME_WAIT
void setup() {
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
}
void
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() {
digitalWrite(motorPin2, HIGH);
}
void left_backward() {
digitalWrite(motorPin2, LOW);
}
void right_forward() {
digitalWrite(motorPin4, HIGH);
}
void right_backward() {
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();
}