Adjustable Countdowntimer using 4×4 Keypad

A short project that can be modified by other users. Once the code is uploaded, TM1637 will display 00:00, after that you can use the 4x4 keypad array to type how long the timer should go (4 digits should be pressesed, 5th press will trigger the countdown, you can press anything for the 5th one). You can use the function at the bottom of the code to modify the result once the timer ends. Note: No code for the letters parts (outer right side of the 4x4 keypad) yet. bugs might be encountered when letters are used.

COMPONENTS AND SUPPLIES

InventrKits HERO

The HERO is a derivative of “Arduino UNO R3 Reference design” we just changed up a few things to make it our own. If you’re curious about what goes into our HERO board we published the open-source hardware files on our GitHub.

1

4x4 Keypad

1

4 Digit Display Module

1

Male to Female Wire

12

ABOUT THIS PROJECT

SCHEMATICS

Adjusable Countdown timer using Keypad

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *

#include #include // Define the connections pins: #define CLKSeg 10 #define DIOSeg 11 TM1637 tm(CLKSeg,DIOSeg); // Create array that turns all segments on: int count = 0; int countStatus = 0; int sec; char customTime[4]; int minTime[2]; char secTime[2]; // Create array that turns all segments off: const byte ROWS = 4; //four rows const byte COLS = 4; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { {‘1′,’2′,’3′,’0’}, {‘4′,’5′,’6′,’0’}, {‘7′,’8′,’9′,’0’}, {‘0′,’0′,’#’,’0′} }; byte rowPins[ROWS] = {6,7,8,9}; //connect to the row pinouts of the keypad byte colPins[COLS] = {2,3,4,5}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); void setup() { Serial.begin(9600); tm.init(); tm.set(2); boot(); } void loop(){ if (countStatus != 0) { displayTime(); } else { keypadGet(); } } void displayTime(){ int minutes = sec / 60; int seconds = sec % 60; tm.display(3, seconds % 10); tm.display(2, seconds / 10 % 10); tm.point(1); tm.display(1, minutes % 10); tm.display(0, minutes / 10 % 10); if(sec <= 0) { alarmHere(); } else { sec--; } delay(1000); } void keypadGet() { char customKey = customKeypad.getKey(); if (customKey) { int customInt = customKey - '0'; if (count != 4) { tm.display(count, customInt); Serial.println(customKey); customTime[count] = customKey; count = count + 1; } else { sec = Getval(); Serial.println(sec); countStatus = 1; } } } int Getval() { minTime[0] = String(customTime[0]).toInt(); minTime[1] = String(customTime[1]).toInt(); secTime[0] = String(customTime[2]).toInt(); secTime[1] = String(customTime[3]).toInt(); String timerTime = String(customTime[1]); int totalMin = (minTime[0] * 10) + minTime[1]; int totaSec = (secTime[0] * 10) + secTime[1]; int totalSec = (totalMin *60) + totalSec; return totalSec; } void boot() { tm.display(3, 0); tm.display(2, 0); tm.point(1); tm.display(1, 0); tm.display(0, 0); } void alarmHere() //put code here for alarm or timer end { }
PROJECT AUTHOR
Leave a comment
TEAM MEMBERS
Belrey

Coding

ADDITIONAL CONTRIBUTORS
Seeed Studio

Grove 4-Digit Display TM1637 Library

TABLE OF CONTENTS
Leave a comment
Share on whatsapp
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest
Share on email

SIMILAR PROJECTS YOU MIGHT LIKE

I cascaded four SN74HC595 shift registers to control 32 LEDs on 4 registers using 3 wires. I am adding a I2C 20×4 LCD screen to display the register and led values. I might add a standard 16×2 LCD screen to show up it is done.
A simple light meter. It’s not calibrated to any meaningful scale, but the digital readout shows a higher number the brighter is the light falling on the photoresistor.