line and wall follower robot

Hello everyone! Not sure if this is the right place to post this, but I hope you guys can help me :slight_smile: I am trying to make a line+wall follower robot. I used PD to implement the line follower and it works really well. I did the same for the wall follower. Now the problem is when I am trying to merge the two programs....the robot will follow the line and when it encounters the wall, it's like it doesn't see it...so basically it follows only the line. Can you guys give me some suggestions/solutions?

P.S. my robot has the proximity sensor (SRF005) on the left side, so the wall will only appear on the left side of the robot. Also I used 7 IR sensors and not the QTR sensor bar.

forum.ino (3.67 KB)

long sensor[]={0,1,2,3,4,5,6};

These values are used as pin numbers. Which Arduino are you using that has negative pin numbers, AND more than 32767 of them?

What do your Serial.print()s tell you is happening?

Why not?