Countdown timer pointers

Hi all, it’s been a while since I have done any programming (1996 turbo pascal)…

Could someone give me a few pointers in the right direction?

Essentially I’m looking to make a countdown timer that can be used to control a 12v motor but I’m stuck at the first hurdle on how to construct the timer. I basically want the motor to stop when the timer expires.

Ideally I want to be able to push a button to increment the timer by say 20s per push with a display probably on an oled of the time remaining. I need to be able to increase the time as the countdown is in progress. Also need to be able to pause and reset.

Any pointers on where to start would be much appreciated.

Thanks in advance …

There is no node to directly count down, but you can use the “count” node to count up and subtract that from the total time. Since you are counting seconds, a “clock” node can be used to pulse the count node. Disable the clock to pause the timer.

You can use a “buffer” node to store the total time for your timer. Remaining time is buffer minus count. When remaining time is less than or equal to zero, stop the motor and disable the clock so your timer doesn’t go negative.

I’m not at my computer to give you a graphic, but button to add 20 seconds to timer is actually pretty easy. The output pin for buffer should be linked to an add node to add 20 to it. This loops back to the input of the buffer node (because it loops back, it will need a defer node between add output and buffer input). The button to add 20 seconds will then pulse the buffer-UPD pin to update to the new value.

Thanks gweimer, that has done the trick (i think i have followed it anyhow). Seems to work in sim, ill attach a display and try it on a board. Thanks for the pointers, im sure ill need a lot more :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.