I’m having problems with my program at the moment.
I’m building a robot, and I’ll try to make clear what the function of the robot must be, otherwise you won’t understand my problem.
You can see it as the following. I have 2 sensors on both side of a box, and the robot will move alongside the box. The program of my robot must begin working after it has passed the second sensor, because when it’s next to the box it will destroy itself when working.
So when the robot starts, it passes the first sensor(SensorValue2), and it must not work.
Therefore, I put in a boolean ‘veilig’ as we call safe in dutch.
When it passes SensorValue2, the boolean has to be set ‘false’, it must not work.
Then it passes the second sensor (Sensorvalue3) and as you can see, when the boolean is set ‘false’ and it passes the second sensor, the programm knows the robot was next to the box, but right now it isn’'t. Because it can see that the robot is moving from sensor 2 to 3.
Therefore, I want to put the boolean 'veilig ’ true.
That’s because there is an possibilty the robot will go back to the zone where the box is.
Cause when it goes back, Sensorvalue3 will give an signal AGAIN. But right now it’s moving to the zone where the box is, so it mustn’t work.
Therefore if Sensorvalue3 is HIGH and 'veilig ’ is true, ist mustn’t work.
But when I pass sensorvalue3 for the first time, the boolean doesnt switch to TRUE.
I dont know why,
Sorry for the complicated question, I hope you guys can help me.
sketch_pwsforum2.ino (1.63 KB)