I want to execute 2 different output at a certain time in seconds. And change the swap time using keyEvent. Here's the idea.

I've been looking for some advice online and I only find those with timer and clock(). I don't need to use timer and clock() since I already use a utilTimer library to count milliseconds as the program is executed.

Here's the my keyEvent code :

Code:

if (key == '1' ) {
mod=10;
}
if (key == '2' ) {
mod=5;
}
if (key == '3' ) {
mod=3;
}
if (key == '4' ) {
mod=1;
}

How do I implement the time loop ? As of now for the looping I'm using mod, but still a little bit confused and haven't achieved my goal.

Code:

for (int count = 0; true; count++) {
if (count % 10 == 0) {
//every 10 seconds
}
if (count % 5 == 0) {
// Every 5 seconds
}
}

Any advice ?