28
delay(time * 100);
}
void right() //turn right
{
digitalWrite(Right_motor_go,LOW); // right motor stop
digitalWrite(Right_motor_back,LOW);
analogWrite(Right_motor_go,0);
analogWrite(Right_motor_back,0);
digitalWrite(Left_motor_go,HIGH);// left motor go ahead
digitalWrite(Left_motor_back,LOW);
analogWrite(Left_motor_go,100);
analogWrite(Left_motor_back,0);// PWM--Pulse Width Modulation(0~255) control
speed
}
void spin_right(int time) //Right rotation
{
digitalWrite(Right_motor_go,LOW); // right motor back off
digitalWrite(Right_motor_back,HIGH);
analogWrite(Right_motor_go,0);
analogWrite(Right_motor_back,200);// PWM--Pulse Width Modulation(0~255) control
speed
digitalWrite(Left_motor_go,HIGH);// left motor go ahead
digitalWrite(Left_motor_back,LOW);
analogWrite(Left_motor_go,200);
analogWrite(Left_motor_back,0);// PWM--Pulse Width Modulation(0~255) control
speed
delay(time * 100);
}
void back(int time) //back off
{
digitalWrite(Right_motor_go,LOW); //right motor back off
digitalWrite(Right_motor_back,HIGH);
analogWrite(Right_motor_go,0);
analogWrite(Right_motor_back,150);// PWM--Pulse Width Modulation(0~255) control
speed
digitalWrite(Left_motor_go,LOW); //left motor back off
digitalWrite(Left_motor_back,HIGH);
analogWrite(Left_motor_go,0);
analogWrite(Left_motor_back,150);// PWM--Pulse Width Modulation(0~255) control
speed
delay(time * 100);
}
//==========================================================
void keysacn()
{
int val;
val=digitalRead(key);// Reads the button ,the level value assigns to val
while(digitalRead(key))// When the button is not pressed
{
val=digitalRead(key);
}
while(!digitalRead(key))// When the button is pressed