Go Down

Topic: Reading data from Monitor using interupts? (Read 1 time) previous topic - next topic

PaulS

On the Arduino side, use Serial.print() to send "Ready" to the serial port, whenever you are ready to read data.

On the PC side, there is an event that needs to be handled whenever serial data arrives. In the event handler, set a variable to true when the incoming serial data is "Ready"

In the sending method, don't send data unless the flag is true. After sending data, set the flag to false.

And follow AWOL's advice to get rid of the delays. Consider a state machine, where the Arduino does stuff only when it is time to do stuff. The thing being done defines the state. When that thing is done, a new state is defined.

Each pass through loop, you see if it is time to do something, based on the current state and the next time to do something/last time something was done. Before doing that, of course, you see if there is any serial data to read, and read it if there is.

Go Up