52
int Right_motor_go = 6;
int Right_motor_back = 10;
int Right_motor_en = 8;
int Left_motor_en = 7;
void setup()
{
//Initialize motor drive for output mode
pinMode(Left_motor_go,OUTPUT);
pinMode(Left_motor_back,OUTPUT);
pinMode(Right_motor_go,OUTPUT);
pinMode(Right_motor_back,OUTPUT);
pinMode(13, OUTPUT);//Show Infrared Remote Control Received Signal
irrecv.enableIRIn(); // Start the receiver
}
void run()
{
digitalWrite(Right_motor_go,HIGH);// right motor go ahead
digitalWrite(Right_motor_back,LOW);
digitalWrite(Left_motor_go,HIGH);// set left motor go ahead
digitalWrite(Left_motor_back,LOW);
}
void brake() //stop
{
digitalWrite(Right_motor_go,LOW);
digitalWrite(Right_motor_back,LOW);
digitalWrite(Left_motor_go,LOW);
digitalWrite(Left_motor_back,LOW);
}
void left()//turn left
{
digitalWrite(Right_motor_go,HIGH); // right motor go ahead
digitalWrite(Right_motor_back,LOW);
digitalWrite(Left_motor_go,LOW); // left motor stop
digitalWrite(Left_motor_back,LOW);
}
void spin_left() //Left rotation
{
digitalWrite(Right_motor_go,HIGH);
// right motor go ahead
digitalWrite(Right_motor_back,LOW);
digitalWrite(Left_motor_go,LOW); // left motor back off
digitalWrite(Left_motor_back,HIGH);
}
void right() //turn right
{
digitalWrite(Right_motor_go,LOW); // right motor stop
digitalWrite(Right_motor_back,LOW);
digitalWrite(Left_motor_go,HIGH);// left motor go ahead
digitalWrite(Left_motor_back,LOW);
}
void spin_right() //Right rotation
{
digitalWrite(Right_motor_go,LOW); // right motor back off