So I'm working with protothreading for an arduino, and I'm running into an issue with the PT_WAIT_UNTIL() method

Here's my function, generally,

static void playNote(struct pt *pt,int n, int L){

  unsigned long tStamp = millis();

  digitalWrite(n, HIGH);
  PT_WAIT_UNTIL(pt, millis()-tStamp > 50);
  digitalWrite(n, LOW);

  tStamp = millis()

  PT_WAIT_UNTIL(pt,millis()-tStamp > L);


Two instances of this function are called in the main loop, and that's all that's in the main loop.

I know it's dead easy to do this without threading, but this project requires that multiple instances of this function be running at once, requiring threading.

So ideally, what this function would do is set the pin 'n' to HIGH, wait 50 ms, then turn it off, wait again for the interval L, and then exit the function.

What I'm seeing is it gets caught up at the first WAIT and does not move on, is there something I'm missing about the setup here?

  • does the protothreading library provide example sketches? ... if yes, then have you tried them? – jsotola Oct 24 '19 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.