LOGIN
Ekhtiak Efat
6
Collaborator
Student (Project Leader)
 · PabnaBangladesh
Share
Report
Get Link
TASK
Open
Reward › Contribution
Estimated Duration › 2 weeks

Code For 5 IR Array Digital Sensor For the robot to follow a black line in white surface

We will add a voice control command to follow a line to work the robot as a line follower. So I need a Arduino coding for 5 IR array (digital signal) to follow the black line. Every working code poster will get contribution

Contributions
Sidharth Thomas

Gave a Line follower robot’s 5IR array sensor’s code

Sidharth Thomas

Great contribution for code.

4 likes 
Like
Award Contribution
Load 8 previous comments
Sidharth Thomas
2
Apprentice
Student
Share
Report
Get Link

I hope this works. I guess you are using a two wheeled chassis with a castor wheel.
If there are any errors or modifications to be made, do inform me.


/* The IR sensor array is to be in the following order:
       L2    L1    M    R1    R2
       
  L1, M and R1 determine the track. L2 and R2 is used for extra precision in very sharp turns.
  
  I have assumed that the IR sensor shows low when detetcting a black surface.
  
  The bot should be placed such that M comes over the black line.
*/        

int L2=8;
int L1=7;
int M=5;
int R1=4;
int R2=3;

int lMotFwd=11;
int rMotFwd=10;
int lMotRev=9;
int rMotRev=6;


void setup()
{
 pinMode(L2,INPUT);
 pinMode(L1,INPUT);
 pinMode(M,INPUT);
 pinMode(R2,INPUT);
 pinMode(R1,INPUT);
 pinMode(lMotFwd,OUTPUT);
 pinMode(rMotFwd,OUTPUT);
 pinMode(lMotRev,OUTPUT);
 pinMode(rMotRev,OUTPUT);

 digitalWrite(lMotFwd,LOW);
 digitalWrite(rMotFwd,LOW);
 digitalWrite(lMotRev,LOW);
 digitalWrite(rMotRev,LOW);
}

void loop()
{
 //A black horizontal Line to denote Start and Stop
 if((digitalRead(L1)==LOW)&&(digitalRead(M)==LOW)
   &&(digitalRead(R1)==LOW))
 {
   digitalWrite(lMotFwd,LOW);
   digitalWrite(rMotFwd,LOW);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }

 //Move forward
 else if((digitalRead(L1)==HIGH)&&(digitalRead(L2)==HIGH)
   &&(digitalRead(R1)==HIGH)&&(digitalRead(R2)==HIGH))
 {
   digitalWrite(lMotFwd,HIGH);
   digitalWrite(rMotFwd,HIGH);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }

 //Less sharp left turn
 else if(digitalRead(L1)==LOW && digitalRead(L2)==HIGH)
 {
   analogWrite(lMotFwd,LOW);
   digitalWrite(rMotFwd,160);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }

 //Very sharp left turn to be taken slowly
 else if(digitalRead(L1)==LOW && digitalRead(L2)==LOW)
 {
   analogWrite(lMotFwd,LOW);
   digitalWrite(rMotFwd,80);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }

 //Less sharp right turn
 else if(digitalRead(R1)==LOW && digitalRead(L2)==HIGH)
 {
   analogWrite(lMotFwd,160);
   digitalWrite(rMotFwd,LOW);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }

 //Very sharp right turn to be taken slowly
 else if(digitalRead(R1)==LOW && digitalRead(R2)==LOW)
 {
   analogWrite(lMotFwd,80);
   digitalWrite(rMotFwd,LOW);
   digitalWrite(lMotRev,LOW);
   digitalWrite(rMotRev,LOW);
 }
 
 delay(5);
}






Contributions

Gave a Line follower robot’s 5IR array sensor’s code

Great contribution for code.

Applicant
Like
1 like 
Award Contribution
Ekhtiak Efat
6
Collaborator
Student (Project Leader)
 · PabnaBangladesh
Share
Report
Get Link

I will check it soon and post review. Thank you @Sidharth Thomas

Like
2 likes 
Award Contribution
Devansh Suri
8
Top Contributor
Collaborizm Robotothon 2017
 · New DelhiIndia
Share
Report
Get Link

awesome

Like
1 like 
Award Contribution
Ekhtiak Efat
6
Collaborator
Student (Project Leader)
 · PabnaBangladesh
Share
Report
Get Link

Devansh Suri thank you 😃

Like
0 like 
Award Contribution
Steven Reubenstone
41
Community Expert
Mechanical Engineer & Tinkerer of Things. Community Moderator.
 · New YorkU.S.
Share
Report
Get Link

this is great teamwork. this is my dream for collaborizm.

Like
1 like 
Award Contribution
Ekhtiak Efat
6
Collaborator
Student (Project Leader)
 · PabnaBangladesh
Share
Report
Get Link

Steven Reubenstone Thank you very much. This is a grat platgorm for learners. As I am a little bit busy now, the working is getting slow. Soon I will start to work fast again. All are helping quite nice in this project 😊😊😊

Like
0 like 
Award Contribution
JOIN TASK
LEAVE A REPLY
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard