Wait between port writes

please format code with </> button * homework policy * asking questions

I’m trying to figure out a way to wait a certain amount of time between sending serial data to my arduino.

I want to be a able to “animate” what gets sent through serial by pressing a button and waiting in between each port.write(). Is there a way to do this in Processing, or is there another program I can use to send serial seperately in a timed way like this?

Hi

You can use delay or millis

Try this example with and without delay

There is other many ways to do what you want

void draw() {
  if (mousePressed == true) {
    
    delay (1000);
    fill(0,255,0);
  } else {
   
    fill(0,0,255);
  }
  rect(5, 5, 150, 150);
}

This is other example for time delay using millis

int start;
int duration = 1500;
void setup() {
  size(600, 600);
  start= millis();
}
void draw() {
   int count = millis() - start;
  if (count> duration) {
    fill(0,255,0);
    rect(0,0,600,600); 
  }
}



Hi @PaladinBobcat, if you look at my example you’ll see it sends on every other draw(); The decision can easily be changed to other logic.