How to implement millis for timed action?
in
Programming Questions
•
1 month ago
Hi!
So I am trying to do this:
click icon
bell sounds
timer begins and
counts 15 minutes
at 15 minute mark
different bell sounds
I have this code, but I cannot get the timer to work or the second bell to sound in mouseReleased, and if I bump it up into void draw, all events happen at the same time -- (am brand new to this) Any help would be great - thank you!
- int passedTime;
- int savedTime15;
- int totalTime15 = 5000; //(currently set for 5 second test)9000000;
void setup()
- int savedTime15 = millis();
void draw()
- int passedTime = millis() - savedTime15;
- totalTime15 = millis() + 5000; //set for 5 second test
void mouseReleased()
- {if (a.mouseReleased())
- {player_open_bell = maxim.loadFile("start_bell.wav");
- player_open_bell.stop();
- player_open_bell.cue(0);
- player_open_bell.play();
- player_open_bell.setLooping(false);}
- if ( a.mouseReleased() - passedTime >= totalTime15 )
- {player_close_bell = maxim.loadFile("end_bell.wav");
- player_close_bell.stop();
- player_close_bell.cue(0);
- player_close_bell.play();
- player_close_bell.setLooping(false);
- println( " 5 seconds have passed! " ); //test
- savedTime15 = millis();}
1