I am just looking to build a simple game for a promotional stand and am after a little guidance.
I have had a good play with the arduino and done a few projects so am not a complete beginner.
What I am looking to do is have an atmega168 connected to small 16x2 lcd and just 2 buttons.
One as a reset the other is the game controller, lets say button A.
When you press button A a 10 second timer is started and every time a button A is pressed a variable increments and it is displayed on the screen (I will be using a big font library after I get it working), until the timer (which is not displayed) hits 0.
Then no furthers pressed will be registered until reset is hit (either software or main).
My main questions are:
A) What is the best method to use as a timer
B) What is the best input function to use in the code
C) Will A + B interfere with each other
Hopefully I can get some hints, after completion I will create a short tutorial complete with the sketch.
The millis() function. Record when loop() starts, if that hasn't been recorded before.
B) What is the best input function to use in the code
To get what? The switch press? That would be digitalRead(). Keep in mind that it is not that the switch is pressed that is important, as much as it is that the switch is now pressed but wasn't before. This means that you need to keep track of the current and previous states.
The millis() function. Record when loop() starts, if that hasn't been recorded before.
B) What is the best input function to use in the code
To get what? The switch press? That would be digitalRead(). Keep in mind that it is not that the switch is pressed that is important, as much as it is that the switch is now pressed but wasn't before. This means that you need to keep track of the current and previous states.
C) Will A + B interfere with each other
No.
Thanks.
I got a rough version running in a few hours.
Click below for the video.