Issue in LINE Follower Code

Hii everyone,
I am making a simple line follower which i will be later on upgrading to grid solver. I am using 5 sensors i.e. IR sender and reciever diodes pair as sensors for the robot.
I am facing an issue regarding the function calls present in the void loop().
When i try writing all the possibilities of tracking the line and individually defining the outputs for each in loop(), my line follower works perfectly. But when i try the same by making individual functions such as left(),right(),straight() and calling them after each “if” condition, the robot doesn’t show any response…
i wanted to know why is it so…? From my point of view it shouldn’t happen… :~
Can anyone tell me where i am going wrong.?
P.S. I have uploaded both the codes.

line_follower2_ino_ino.ino (1.56 KB)

line_follower2_1call_ino.ino (1.47 KB)

For such small sketches, you could have posted then directly, rather than attachments.

void right()

You'd already defined these as pin numbers. Assigning those pin numbers to the same pins you'd normally be using for the serial interface isn't the best idea ever.

ohh srry,! its my first post so didn't knew how to do that.. and thank you very much for the reply.. :) So, what are the changes i should make to use such function calls...? I want to call respective functions rather than simply coding them into the loop() as i said earlier i need to upgrade it into grid solver... I am new to these stuffs, although not new to programming.. :P need ur help...

I'd qualify the pin numbers with "const", then any attempt to reassign them would give you a compiler error. Then I'd figure out the difference between a pin number and the value you write to it.

Thank you very much for explaining me the difference… i found my mistake…

couldn't believe how i didn"t noticed that.... =( :.

i am also having some problems regarding this code, can you pls give me ur final code after correction ?? @Amamn24

Ankushbose: i am also having some problems regarding this code, can you pls give me ur final code after correction ?? @Amamn24

This is a two year old thread.