Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Wait for Arduino Before Sending Data Over Serial

$
0
0
I ended up solving it with the following:

In my Processing program, I added a section that paused in a while loop every 32 iterations until it receives feedback from the arduino (and also sends a 'Y' character to let the arduino know that it's paused), then continues with the main void draw()

  1. void draw() {  

  2. ++waiting;
  3. if(waiting==32) {
  4.   arduinoPort.write('Y');
  5.   while (1==1) {
  6.     int inByte = arduinoPort.read();
  7.     if(inByte == 78) {
  8.       break;
  9.     }
  10.   }
  11.   waiting = 1;
  12. }
and in my arduino code, I just added  a section specifying that if the Processing program is paused, send an 'N' lo let it know to continue.

  1.     else if (hit == 89) {
  2.       Serial.print('N');
  3.     }

Viewing all articles
Browse latest Browse all 1768

Trending Articles