This is just a simple timer. Run this code and I think you’ll understand.
int x = 0;
int time_interval = 1000;
int start_time = 0;
void setup() {
size(100, 100);
}
void draw() {
if (millis()-start_time >= time_interval) {
start_time = millis();
println(x);
x++;
}
}