please format your code posting here at forum
( topic editor )
by pasting it into the
</> code button
of the editor header menu ( context name: Preformatted text )
it looks like
```
type or paste code here
```
also can use the ``` manually above and below your code.
or select the already pasted “code” and use [ctrl][shift][c]
thank you.
also we recommend that the code from processing IDE ( PDE )
is formatted there first, like with /Edit/Auto Format/ or [ctrl][t]
now we need you to REPAIR your above CODE POSTING,
not make a new / better post.
( just think about the hundred people opening your topic in the future )
If you have an experience using the function delay () then you know that it freezes everything that the program is doing then proceeds to the following code after a certain amount of time.
Surely this is not so useful most of the time. Instead, I recommend taking a look at the function millis () instead. You can learn more about it from the Processing references but for now, know that it returns the number of milliseconds since the starting of the program. This can be turned into use as you’ll see below.
Here I’ve crafted you a very simple way of implementing it.
long lastTime;
int patience = 5000; // 5000 milliseconds > 5 seconds
void setup () {
}
void draw () {
if(millis () - lastTime > patience) {
// Do something you want to be done periodically here
print ("Horray!");
// Update lastTime so that it can serve as a new reference time
lastTime = millis ();
}
}
After you got a hang of that, you can create your own class to keep things neat. Or click here to find a class I made.