how can repeat every code 5 sec forver?
i try to find about that,
i cant find “repeat using time”
here draw() runs on and on
- but i is incremented only once every 3 seconds
int timer;
int i;
String textSlash="/";
void setup() {
size(600, 600);
timer = millis();
background(0);
}
void draw() {
background(0);
text("3 seconds have passed "+i, 44, 44);
// This gets executed every 3 secs - while draw() keeps on running 60 times per second
if (millis() - timer > 3000) {
timer = millis(); // reset timer for next round
i++; // increase i once every 3 secs
}
// do something else to show that draw() runs fast
if (frameCount%9==0)
if (textSlash.equals("\\")) {
textSlash="/";
} else {
textSlash="\\";
}
text(textSlash, 111, 111);
}