I am working on a line tracking robot and have completed all of the appropriate code. However, it is required that the robot stop at the end of the line. One way I thought about going through this is by getting an average time of how long the robot takes to complete the task. Then creating an if statement where if after 65 seconds and all 3 sensors are equal to each other, turn off the robot. How would I go about this in easyc?
If you’ve got three line trackers, just include a statement that if none of them read the line you stop. That’s “if” with three conditions connected by “and” inside. If the whole robot needs to be off the line instead of where you’re reading, you can follow this with a drive forward command to move it far enough. Three sensors make things like this so much easier. If you had only one it would be far trickier.
If you want to stop the function after a certain amount of time, you could try using a timer function. I don’t know how to use easyC, so I’m just going to list steps.
At the beginning of the line tracking, reset the timer. Put the line tracking code inside of a while loop with the condition set to something along the lines of
(sensor value code) || timer[T1] <= 65000
When the timer goes over the time limit, it should wait until all sensor values are correct and then break the loop.
I hope this helped in some way.