Programming/wiring an Arduino countdown? :)


#1

I started a new job today (at a VR arcade!) and I need to make some countdown timers for each VR booth. I need it to count down from 60 minutes or 30 minutes based off of a button press. Is there someone here who can help me get this programmed and could help me figure out components/wiring? I may be able to help a little with compensation for the time/effort through the arcade. (I’ll ask the boss lady in the morning)

For parts I am thinking:
Display: https://www.adafruit.com/product/880
Buttons for selecting duration and starting: https://www.adafruit.com/product/560
Power button: https://www.adafruit.com/product/3104
Ardunio: Nano?
Resistors: 10k (for buttons)

I can do all the wiring/soldering, once I know what goes where. Haha.

A hugggeeee thank you to anyone who may be able to help!!

PS I eventually would like to cut wooden housing for these when I get my laser. :smiley:


#2

You can totally do it!
I like this one:


#3

Here’s the fill in the blank coding:

CountDownTimer() : The timer itself (This is the constructor in the library)
Timer() : (This is the actual timer in the library)
TimeHasChanged() : This returns true if the time has changed (in seconds)
SetTimer() : Input the time to count from, Format: H,M,S or just seconds ie. 3600 = 1 hour
StartTimer() : Start the timer sequence
StopTimer() : Stops the Timer completely
StopTimerAt() : Stops the timer at a specific time, Format: H,M,S
PauseTimer() : Pauses the timer until told to resume
ResumeTimer() : Resume timer from where it was paused at
ResetTimer() : This starts the timer over from the initial setTime

TimeCheck() : Returns true if the time is equal to particular time
ShowMicroSeconds() : Returns the current Microseconds
ShowMilliSeconds() : Returns the current Milliseconds
ShowSeconds() : Returns the current Seconds
ShowMinutes() : Returns the current Minutes
ShowHours() : Returns the current Hours


#4

You should totally be able to find some sample code as a good starting point for this.
But I would be happy to help you if you get stuck.

Those rugged buttons are great. I used them recently on a project and they look awesome.


#5

Just looking at the page for the display and it looks fairly simple to setup.
You should be able to run the display and buttons off a arduino nano, which can be found really cheap.
Make sure to also grab some 10k resistors for the buttons.


#6

Oh you guys are the best!!! I knew you’d be able to help! Haha

That sample code is great! I just wouldn’t know how to write the whole thing lol. I have tried soooo many times to learn but my brain isn’t wired that way. :stuck_out_tongue:


#7

Yeah, I really liked the look of the buttons. Veryy slick!!

Oh awesome!! Nano it is!! Haha.


#8

You’re awesome for providing the link and the fill-in-the-blank coding. It looks like a fun project.

Thanks!


#9

This should be a piece of cake. One caveat is that you might want a latching switch for the power button? At learn.adafruit.com (linked from the product pages) they’ve got tutorials and libraries for the LED and other parts. (I’ve used a backpack like that to make a lidar rangefinder – the only thing that’s a little fiddly is remembering the leading zeros/blanks.)

As for arduinos, I would kinda recommend against the Trinket line because they don’t always play well with USB connections for programming. I’ve used a lot of metro minis, offbrand arduino nano clones, and some Teensies and Feathers. If reduced expenditure of brainpower is important for you, you might also want to consider Adafruit’s breadboard-like protoboards – sometimes figuring out your own connection grid just isn’t worth it.

fun! (Also, think if you want anything interesting to happen as you near or reach zero…)


#10

I now use the feathers, and they’re great. I mostly use the m0 based ones with wifi. Integrated battery management


#11

If this is something you want to do, great. If not, a bit of Googleing should produce something that works well for around half the cost.
I love Arduino but I don’t believe in reinventing the wheel.


#12

Resistors for buttons not needed with the Arduino. You can enable an internal pullup resistor when you declare the input in the code. Just connect the switch between the input pin and ground and you’re good to go.

But I have to agree with @markevans36301, the Arduino would be appropriate for doing some unusual customized behavior, but for your described application, I bet you could do better with an existing timer product.


#13

A quick Amazoogle (that’s search in Amazon) for “countdown timer module” found this:

It’s not exactly what you need since it only goes up to 999 sec.

I assume you want something to happen when the time is up, right? The module has the ability to to do that (using the built-in relay) to turn on a buzzer, or turn off the booth, or whatever.

And all for about $5.

Here is a more capable unit that will countdown up to 9999 minutes:

It will also let you trigger some action. It has four timers, and one can trigger the next, so you could have four distinct phases during the 30 min or 60 min booth time.


#14

Keep in mind that the second device shows the countdown on an LCD screen, which may not even be lit. If you want the booth occupant to see the countdown, it may not be suitable.

If you want large lit numbers visible in the booth, then the Arduino approach might prove to be the best bet.


#15

Another option…


#16

Good to know, i’ve always been told to use a resistors.


#17

I agree, good to know. I’ve read about pull-up resistors but don’t really get the jist of it. I like mechanical things, and very little electrical things. Anyone willing to explain the idea of a pull-up resistor? @ianauch or @Scott.Burns?


#18

Sure. An input pin needs to be connected “enough” to either ground or to +V to register a LOW or HIGH state. If left unconnected, it becomes very susceptible to the environment around it and can switch between HIGH and LOW in a seemingly random way.

If you connect a switch between the pin and either ground or +V, and the switch is closed (i.e. conducting), then the input pin is solidly locked into one state (LOW if connected to ground, or HIGH if to +V). But when you open the switch (make it non-conducting), then the pin is essentially unconnected and will give unreliable readings.

To prevent this, a resistor is added between the pin and whichever voltage level (ground or +V) the switch is NOT connected to. That way, when the switch is open, the resistor makes enough of a connection to the ground or +V to put the input pin into a reliable state. When the switch is closed, it provides a much better connection, and dwarfs the effect of the resistor.

That was a lot of words. Maybe an image will be better:

The left case would register a HIGH when the switch is open (as shown). The right case would register a LOW when it’s open.

The Arduino has an optional pull-up resistor inside, so it resembles the left case, and you only need to connect the switch to ground.

Does this make sense?


#19

Ah! That makes sense now, thanks!

If you didn’t have the resistor in the left schematic, the pin would just be floating. However, with the resistor in there, and the switch open, the path of least resistance is to V+ (compared to arcing across the air gaps in the switch to go to ground) and would register HIGH. But when the switch is closed, then the path of least resistance is through the switch to ground instead of through the resistor to V+, registering LOW. Did I reiterate this correctly?

So, why are 10k ohm resistors used? Because they’re much larger than the resistance of a typical electrical circuit?


#20

The large resistor is there because when the switch is pressed it is a direct circuit between the power supply and ground. The large value resistor keeps the switch from drawing too much current. :relaxed: