int LA=14;
int LB=15;
int RA=16;
int RB=17;
int EN1=3;
int EN2=5;
void setup()
{
pinMode(LA,OUTPUT);
pinMode(LB,OUTPUT);
pinMode(RA,OUTPUT);
pinMode(RB,OUTPUT);
pinMode(EN1,OUTPUT);
pinMode(EN2,OUTPUT);
}
void loop()
{
forward(1);
left(1);
}
void forward(int a)
{
analogWrite(EN1,150);
digitalWrite(LA,HIGH);
digitalWrite(LB,LOW);
analogWrite(EN2,164);
digitalWrite(RA,HIGH);
digitalWrite(RB,LOW);
delay(a*1000);
}
void back(int b)
{
analogWrite(EN1,150);
digitalWrite(LA,LOW);
digitalWrite(LB,HIGH);
analogWrite(EN2,188);
digitalWrite(RA,LOW);
digitalWrite(RB,HIGH);
delay(b*1000);
}
void left(int c)
{
analogWrite(EN1,0);
digitalWrite(LA,LOW);
digitalWrite(LB,LOW);
analogWrite(EN2,207);
digitalWrite(RA,HIGH);
digitalWrite(RB,LOW);
delay(c*1000);
}
void right(double d)
{
analogWrite(EN1,150);
digitalWrite(LA,HIGH);
digitalWrite(LB,LOW);
analogWrite(EN2,150);
digitalWrite(RA,LOW);
digitalWrite(RB,LOW);
delay(d*1000);
}
void square()
{
forward(1);
left(1);
forward(1);
left(1);
forward(1);
left(1);
forward(1);
left(1);
}
int LB=15;
int RA=16;
int RB=17;
int EN1=3;
int EN2=5;
void setup()
{
pinMode(LA,OUTPUT);
pinMode(LB,OUTPUT);
pinMode(RA,OUTPUT);
pinMode(RB,OUTPUT);
pinMode(EN1,OUTPUT);
pinMode(EN2,OUTPUT);
}
void loop()
{
forward(1);
left(1);
}
void forward(int a)
{
analogWrite(EN1,150);
digitalWrite(LA,HIGH);
digitalWrite(LB,LOW);
analogWrite(EN2,164);
digitalWrite(RA,HIGH);
digitalWrite(RB,LOW);
delay(a*1000);
}
void back(int b)
{
analogWrite(EN1,150);
digitalWrite(LA,LOW);
digitalWrite(LB,HIGH);
analogWrite(EN2,188);
digitalWrite(RA,LOW);
digitalWrite(RB,HIGH);
delay(b*1000);
}
void left(int c)
{
analogWrite(EN1,0);
digitalWrite(LA,LOW);
digitalWrite(LB,LOW);
analogWrite(EN2,207);
digitalWrite(RA,HIGH);
digitalWrite(RB,LOW);
delay(c*1000);
}
void right(double d)
{
analogWrite(EN1,150);
digitalWrite(LA,HIGH);
digitalWrite(LB,LOW);
analogWrite(EN2,150);
digitalWrite(RA,LOW);
digitalWrite(RB,LOW);
delay(d*1000);
}
void square()
{
forward(1);
left(1);
forward(1);
left(1);
forward(1);
left(1);
forward(1);
left(1);
}