I have designed a GUI in Processing in which when the user presses a button, a "\n" is sent over to the serial port and the Arduino should be able to detect that and break out of the "while" loop and then wait for other inputs to determine what the Arduino should do next. The problem is the user may press the button during one of those delays, or while the instructions are being executed. How do I avoid missing those clicks?
I had the idea that maybe I could send the "\n" over and over again, once the button has been pressed. But then it would mess with the next commands the user would want to send.
AWOL:
You didn't actually post any code, remember?
Hence the quotation marks.
Here's some explanation:
I'm generating a certain waveform. In order to do that, I need to set a few I/O pins to 1 or 0 for a certain amount of time. The delays help with the timing. The for loops are needed because of the waveform that I'm going for.
What he is trying to say is that you should post all of your code and place them into code blocks.
There is no need to have a blocking while inside your loop. The first link I presented will teach you how to NOT use delay, the sooner you learn to not use it the better you are.
There is no use for any delay() call, except for convenience during quick tests. A delay() stops you from doing other things. That's why you have to get rid of them. There is even less use for a while(1) loop.
So yes, basically all of the "code" you posted has to go.
If you need precise timing you can use the millis() or micros() functions, if that's not good enough timer interrupts.
Mylaiza:
Here's some explanation:
I'm generating a certain waveform. In order to do that, I need to set a few I/O pins to 1 or 0 for a certain amount of time. The delays help with the timing. The for loops are needed because of the waveform that I'm going for.
Seventeen posts prior to this particular foray, we might have expected you to do some reading of other problems by way of research.