Basic "Timer"

Alright here's the scenario:

Some guys and I have each been tasked with making the differenct parts of a game. Our game involves a series of LED's that light up, and the player must press the corresponding button in the same order. My section of the code was the timer, which would give the player 1 and a half second to press the next right button before resetting and giving another 1 and a half second to press the next one and so on. I just want some pointers to lead me in the right direction, please :)

You say your section was the timer. Who's is it now? To help, we need to see the code.

Sorry, my section is the timer.

So far all I've done is set up the function block, we're in an introductory arduino class. My biggest problem is not knowing where to begin. Someone gave me the idea to start the timer at zero and use mod to find out when it reaches 90 to initiate the "losing" function, but I need help starting the timer.

Where does "90" come from?

You should start by reading up on the millis() reference. Learn how to calculate "time" with the Arduino.

http://www.arduino.cc/en/Reference/Millis

This is easy if your using a standard Arduino processor.

Sorry, 90 seconds, which is a minute and a half :slight_smile:
Thanks for the reference!

Alright, so it should be pretty simple for me to take that command, use an "If" statement and say that if the mod of the milliseconds since the program started is 0 then the end function runs... But how do I reset the programs millisecond counter when they press the right button?

You don't reset the counter, you use your own"zero"

So I can set up my own variable and have it increment itself every second, or reset back to zero when the correct button is pushed?

Yes, something like that.
Depends what your code looks like.

Maybe Marcello Romani's SimpleTimer Library for Arduino will help. http://www.arduino.cc/playground/Code/SimpleTimer