I want to make a line follower code. Initially the robot path using a light sensor, and will stop if any obstacle without crashing into obstacles with the help of sonar sensors. after that the "wait for push button" robots to run again but all the sensors turned off, and the robot goes according to the previous track. how? please help

A quick glance through the code you've posted looks like it should work (assuming the light/dark readings are accurate and the threshold value is calculated correctly) to line-track the robot within 30 cm of an object detected by the sonar sensor.

To move the robot back to the start (following the same path) without using sensors, however, will increase the complexity of this program by quite a large amount. Basically, you will need to 'record' the encoder values of the wheels after each movement, store it in an array of variables, then 'replay' the movement in reverse once you're done. The problem is that the length of the track can easily fill up the maximum array values quickly and cause you to run into an overflow issue.

Is there any way that you could possibly turn the robot around and line track backwards (without using the sonar sensor, but rather the encoder values)? This would greatly simplify the program for you, if possible. If not, how long of a track are you looking at?

Ah I see the problem now, I apologize for the confusion. Just to clarify, the robot will use a light sensor to track a line forward until the sonar sensor detects an object. When it does, the robot will stop, be physically moved back to the starting point, and (when a touch sensor is pressed by the user) move forward for the same distance as the original run (but this time without using the sonar or light sensors), correct?

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum