Up Down Counter design based on Arduino MEGA compatible board is the topic of this article.it uses 2×16 LCD display to show the counter values and 4×3 keypad to input initial 3 digit number.The counter will count Up/Down according to a chosen direction * – Up,# – Down. Nevertheless the count will stop at “000”. At this point A0 output will be toggled ON/OFF with 100ms delay until a new counter value is entered via keypad. You can download attached Arduino sketch at this link . Test this code by entering an initial value via keypad. Numbers from 0 and up to 999 seconds can be entered . Design schematic is shown next:
The code is actually a modified version of a countdown timer, see this link. Keypad matrix debouncing is dealt with by inserting a short delay between each keypad scan.
In case multiple digits being received with single key pressed modify delay() function. A relay or solid state switch can be added to A0 if higher output current is needed.