All the examples of while and do/while are using a counter rather than inputs in the loop. I have a project that times an object between two points bidirectionally. It works very well in most cases. When the object reaches the exit it triggers an LCD message for 10 seconds. This, of course, keeps the sketch from doing anything else.
The problem occurs when the object is still sensed at the exiting end after the 10 second display, causing it to appear to be an entry from that end of the timing section. I thought I could hold this off with a while loop using the inputs, but it fails. This may be just because of it's location in the sketch or maybe there is another issue that I'm overlooking.
DR_PIN and DL_PIN are the two sensor inputs with pullup resistors. Sorry, but I don't want to give the entire code here as I wish to publish it elsewhere.
Just a measure of this annoying forum interface - once you start typing a response, you get no display update of other responses until you click Reply, at which point "Oh shirt, someone already said that". No big deal.
No, as I said I hope to publish this elsewhere and I won't give it away. This is just 8 lines out of 164 where the problem used to lie. Everything else works perfectly.
DR_PIN = Detector Right input pin DL_PIN = Detector Left input pin