a time loop
in
Programming Questions
•
10 months ago
Hey guys!
I have a simple time-counter that counts seconds and prints them on the panel. 180 sec. represent a day and between these seconds I trigger some events. Here is the general configuration:
...
int time; // a counter for time triggering events
int wait = 1000;
...
void setup() {
time = millis();//store the current time
...
void draw() {
...
//check the difference between now and the previously stored time is greater than the wait interval
if(millis() - time >= wait){
println(time/1000);//if it is, do something
time = millis();//also update the stored time
}
...
if (time/1000>30 && time/1000<90) {
"statement"
}
...etc
the thing is that AFTER the 180 sec. I want to go back to time/1000 = 0 and start counting from the beginning, in order to
loop the events.
Does anyone know how am I supposed to do that? I think I might use an
int day = 180 and an
int loop = 0 (representing the amount of days passed) but I 'm not sure... :(
1