Skip to main content

Line Follower Robot for beginers with arduino

hello guys welcome back again
sorry for very long time


i am gonna show you about PID based line follower robot
so what is pid

PID :

consept of pid is war with errors.
we try to programme a controller to automatically solve error by it self 

ERROR of Line follower robot : 
when ever line follower leave the black line it stops detecting so this programme teach controller that how to solve this problem automatically.



Line follower:
basically everyone knows that line follower needs ir sensor but you can also use color sensor but it is too costly than ir.
so we are going to use ir sensor and photodiode.


components :
5×ir leds
5×photodiodes
1×arduino
opamp
l293d



note: this is just helping gude you can copy programme but you have to make circuits by your self because it does not make any sense that i will tell you every thing about robot

i have show video below that how is this programe work

and its proof that this programme is working


i have described previously that have won in university by this robot.





programme :




int la = 8;
int lb = 9;
int lc = 10;
int ld = 11;
int le = 12;
int L1=2;
int L2=3;
int R1=4;
int R2=5;
int a=0;
int b=0;
int c=0;
int d =0;
int e=0;
int L = 13;
char q=0;

void setup()
{
  Serial.begin(9600);
   pinMode(la,INPUT);
   pinMode(lb,INPUT);
   pinMode(lc,INPUT);
   pinMode(ld,INPUT);
   pinMode(le,INPUT);
   pinMode(L1,OUTPUT);
   pinMode(L2,OUTPUT);
   pinMode(R1,OUTPUT);
   pinMode(R2,OUTPUT);
   pinMode(L,OUTPUT);
}
void loop()
{
  a=digitalRead(la);
  b=digitalRead(lb);
  c=digitalRead(lc);
  d=digitalRead(ld);
  e=digitalRead(le);
  if( a== 0 ){
   f_left();
   q='a';
  }
  else if ( b == 0 ){
   left();
   q='b';
  }
  else if (c==0){
    fow();
    q='c';
  }
  else if(d==0){
   right();
   q='d';
  }
  else if(e==0){
   f_right();
   q='e';
  }
 else if(d == 0 && e == 0){
    f_right();
    q='e';
 }
  else if ( a==0 && b==0){
     f_left();
     q='a';
  } 
  else if( b==0 && e==0&& d==0 && c==0){
    f_right();
    q='e';
  }
    else if(a==0 && b==0 && c==0 && d==0){
     f_left();
     q='a';
  }
     else if(a==1 && b==1 && c==1 && d==1 && e==1){ 
         if(q=='a'){
            f_left();
          }
         else if(q=='b')
            f_left();
          else if(q=='d')
            f_right();
          else if(q=='e')
            f_right();
          else if(q=='c')
            fow();
          else
          {
            led();
            delay(500);
            les();
            delay(500);
            led();
            stp();
          }
        }
       
  
  else if(a==0 && b==0 && c==0 && d==0 && e==0){
         if(q=='a'){
            f_left();
          }
          else if(q=='b'){
            f_left();
         }
          else if(q=='d'){
            f_right();
          }
          else if(q=='e'){
            f_right();
          }
          else
          {
            led();
            delay(500);
            les();
            delay(500);
            led();
            stp();
          }
  }
}



void fow(){
  digitalWrite(L1,HIGH);
  digitalWrite(L2,LOW);
  digitalWrite(R1,HIGH);
  digitalWrite(R2,LOW);
}
void rev(){
  digitalWrite(L1,LOW);
  digitalWrite(L2,HIGH);
  digitalWrite(R1,LOW);
  digitalWrite(R2,HIGH);
}
void f_right(){
  digitalWrite(L1,HIGH);
  digitalWrite(L2,LOW);
  digitalWrite(R1,LOW);
  digitalWrite(R2,HIGH);
}
void f_left(){
  digitalWrite(L1,LOW);
  digitalWrite(L2,HIGH);
  digitalWrite(R1,HIGH);
  digitalWrite(R2,LOW);
}
void right(){
  digitalWrite(L1,HIGH);
  digitalWrite(L2,LOW);
  digitalWrite(R1,LOW);
  digitalWrite(R2,LOW);   
}
void left(){
  digitalWrite(L1,LOW);
  digitalWrite(L2,LOW);
  digitalWrite(R1,HIGH);
  digitalWrite(R2,LOW);
}
void stp()
{
  digitalWrite(L1,LOW);
  digitalWrite(L2,LOW);
  digitalWrite(R1,LOW);
  digitalWrite(R2,LOW);
  
}
void led(){
  digitalWrite(L,HIGH);
}
void les(){
  digitalWrite(L,LOW);
}













its very basic programme and its for beginners

thank you.
if you have any query mail me every time
comment and follow.

 IF YOU FEEL THIS CODE WORK FOR YOUR PROJECTS 
AND WANT MORE . I WISH YOU DONATE 

Comments

Popular posts from this blog

How to install swift in arch linux

IN aur i have tried 3 days off. oh shit no errors and errors finally found this method not appropriate. but till aur errors resolved so this it. Fish shell users: set -x LD_LIBRARY_PATH  "download path" (do not include usr directory ) you have to set variable for everytime you want to run swift but there is a method for universal environmental variable. bash users: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<download path> thats it . this is how you can run swift in any linux machine. till official support announce. thank you. My Apps Android: P Music Player  Find Mechanics near You  (my startup) Please download  it will appreciate. and comment me for improvement.

Python Reads gmail

This is tutorial on how to read gmail emails with python programme : ----------------- #!/usr/bin/python __author__ = 'Robokishan' import email import imaplib import ctypes import getpass mail = imaplib.IMAP4_SSL('imap.gmail.com',993) unm = raw_input("insert Email : ") #pwd = raw_input("insert password : ") pwd = getpass.getpass("input : ") mail.login(unm,pwd) mail.select("INBOX") def loop():    mail.select("INBOX")    n=0    (retcode, messages) = mail.search(None, '(UNSEEN)')    if retcode == 'OK':             for num in messages[0].split() :          #print 'Processing '          n=n+1          print n          typ, data = mail.fetch(num,'(RFC822)')          for response_part in data:             if isinstance(response_part, tuple):                 original = email.message_from_string(response_part[1])                 print original['From']        

All Android Manifest permissions

<uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM"/> <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY"/> <uses-permission android:name="android.permission.ACCESS_DRM_CERTIFICATES"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FM_RADIO"/> <uses-permission android:name="android.permission.ACCESS_IMS_CALL_SERVICE"/> <uses-permission android:name="android.permission.ACCESS_INPUT_FLINGER"/> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE"/> <uses-permission android:name="an