Arduino Line Follower robot usingUno R3
Materials used : 8 array IR LED sensors, relimate conectors,Arduino Uno board,L293D motor driver Circuit. 200 RPM DC motors.
Details : for details for making the line follower using AVR, click here for both code and further details.
SIDE VIEW
TOP VIEW
TOP VIEW
Code : Arduino IDE using software
//to control speed of the robot using the function written within "//".
int rmf=12;
int rmr=13;
int lmf=11;
int lmr=10;
int xxls=2;
int xls=3;
int ls=4;
int cs1=5;
int cs2=6;
int rs=7;
int xrs=8;
int xxrs=9;
//int en1=any pwm pin;
//int en2=any pwm pin;
void setup()
{
pinMode(rmf,OUTPUT);
pinMode(rmr,OUTPUT);
pinMode(lmf,OUTPUT);
pinMode(lmr,OUTPUT);
pinMode(xxls,INPUT);
pinMode(xls,INPUT);
pinMode(ls,INPUT);
pinMode(cs1,INPUT);
pinMode(cs2,INPUT);
pinMode(rs,INPUT);
pinMode(xrs,INPUT);
pinMode(xxrs,INPUT);
Serial.begin(9600);
//speed ranges from 0 to 255
//0=low
//255=full speed
//analogWrite(en1,255)
//analogWrite(en2,255)
}
void loop()
{
int sxxls=digitalRead(xxls);
int sxls=digitalRead(xls);
int sls=digitalRead(ls);
int scs1=digitalRead(cs1);
int scs2=digitalRead(cs2);
int srs=digitalRead(rs);
int sxrs=digitalRead(xrs);
int sxxrs=digitalRead(xxrs);
Serial.print(sxxls);
Serial.print(" ");
Serial.print(sxls);
Serial.print(" ");
Serial.print(sls);
Serial.print(" ");
Serial.print(scs1);
Serial.print(" ");
Serial.print(scs2);
Serial.print(" ");
Serial.print(srs);
Serial.print(" ");
Serial.print(sxrs);
Serial.print(" ");
Serial.print(sxxrs);
Serial.println(" ");
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==LOW && scs2==LOW && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,LOW);
digitalWrite(rmf,LOW);
delay(10);
}
if(sxxls==HIGH && sxls==HIGH && sls==HIGH && scs1==HIGH && scs2==HIGH && srs==HIGH && sxrs==HIGH && sxxrs==HIGH)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==HIGH && scs2==HIGH && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==HIGH || sxls==HIGH && sls==HIGH && scs1==HIGH && scs2==HIGH && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,LOW);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==HIGH && scs2==HIGH && srs==HIGH && sxrs==HIGH || sxxrs==HIGH)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,LOW);
delay(10);
}
}
int rmf=12;
int rmr=13;
int lmf=11;
int lmr=10;
int xxls=2;
int xls=3;
int ls=4;
int cs1=5;
int cs2=6;
int rs=7;
int xrs=8;
int xxrs=9;
//int en1=any pwm pin;
//int en2=any pwm pin;
void setup()
{
pinMode(rmf,OUTPUT);
pinMode(rmr,OUTPUT);
pinMode(lmf,OUTPUT);
pinMode(lmr,OUTPUT);
pinMode(xxls,INPUT);
pinMode(xls,INPUT);
pinMode(ls,INPUT);
pinMode(cs1,INPUT);
pinMode(cs2,INPUT);
pinMode(rs,INPUT);
pinMode(xrs,INPUT);
pinMode(xxrs,INPUT);
Serial.begin(9600);
//speed ranges from 0 to 255
//0=low
//255=full speed
//analogWrite(en1,255)
//analogWrite(en2,255)
}
void loop()
{
int sxxls=digitalRead(xxls);
int sxls=digitalRead(xls);
int sls=digitalRead(ls);
int scs1=digitalRead(cs1);
int scs2=digitalRead(cs2);
int srs=digitalRead(rs);
int sxrs=digitalRead(xrs);
int sxxrs=digitalRead(xxrs);
Serial.print(sxxls);
Serial.print(" ");
Serial.print(sxls);
Serial.print(" ");
Serial.print(sls);
Serial.print(" ");
Serial.print(scs1);
Serial.print(" ");
Serial.print(scs2);
Serial.print(" ");
Serial.print(srs);
Serial.print(" ");
Serial.print(sxrs);
Serial.print(" ");
Serial.print(sxxrs);
Serial.println(" ");
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==LOW && scs2==LOW && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,LOW);
digitalWrite(rmf,LOW);
delay(10);
}
if(sxxls==HIGH && sxls==HIGH && sls==HIGH && scs1==HIGH && scs2==HIGH && srs==HIGH && sxrs==HIGH && sxxrs==HIGH)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==HIGH && scs2==HIGH && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==HIGH || sxls==HIGH && sls==HIGH && scs1==HIGH && scs2==HIGH && srs==LOW && sxrs==LOW && sxxrs==LOW)
{
digitalWrite(lmf,LOW);
digitalWrite(rmf,HIGH);
delay(10);
}
if(sxxls==LOW && sxls==LOW && sls==LOW && scs1==HIGH && scs2==HIGH && srs==HIGH && sxrs==HIGH || sxxrs==HIGH)
{
digitalWrite(lmf,HIGH);
digitalWrite(rmf,LOW);
delay(10);
}
}
No comments:
Post a Comment