Countdown timer using Arduino, LCD 16×2 i2c & 4×3 Keypad

(Last Updated On: July 6, 2020)

Countdown Timer

Description:

Countdown timer using Arduino- in this tutorial, you will learn how to make an advanced level Countdown timer based on the Arduino, 16×2 i2c LCD, and a 4×3 keypad. This countdown timer is entirely different from the rest of the countdown timers available on the internet. This countdown timer can be used as the end product. With the help of this Countdown timer, you can control different types of electrical loads like for example Light Bulbs, Heaters, Water Pumps, Washing Machines, Fans, etc. in fact, this countdown timer can be used anywhere where you need to control anything on the time basis. This countdown timer is ideal for AC and DC loads.

Before, I am going to explain the circuit diagram of the Arduino based countdown timer, Simulation, and programming; first I am going to explain how this project actually works.

Using this Arduino based countdown timer is very simple; the instructions are displayed on the 16×2 LCD. The user simply enter the time in minutes and seconds and press the Asterisks “*” key on the Keypad. The total time is displayed in seconds. The timer is started which is based on the millis function. The load which is connected with the relay is turned ON. This load will remain ON until the total seconds’ decrements to 0.

If at any time you need to change the minutes and seconds, you can simply press the Hash “#” key on the keypad which will take you back to the main screen, and you can start again by entering the minutes and seconds.

Without any further delay let’s get started!!!


Note: for practical demonstration and complete project explanation watch video given at the end of this article.

Amazon Purchase Links:

Arduino Uno: https://amzn.to/3bHCaTL

LCD 16×2 i2c: https://amzn.to/2vF4zJL

4×3 Keypad: https://amzn.to/38Eck12

12v SPDT type Relay Module: https://amzn.to/2SUhhw7

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



What is a timer and its types:

A timer is a specially designed clock that is used for measuring specific timer intervals. Timers can be divided into two main types. A timer which is capable of counting time intervals upwards from zero for measuring the elapsed time is usually called a stopwatch, while on the other hand a device or a clock which counts down from a specified time interval is more usually called a timer, which is also known as the countdown timer.

About the 4×3 keypad:

Countdown Timer

This is the 4×3 keypad, 4×3 means that this keypad has 4 rows and 3 columns. The first contact is the C1, 2nd one is the R0, 3rd contact is the C0, 4th contact is the R3, 5th contact is the C2, 6th contact is the R2, and 7th contact is the R1.

You can also use a 4×4 keypad; leave the 4th column c4 unconnected. As you can see the 4×3 keypad has no headers and wires, due to which it can’t be interfaced with the Arduino.

Countdown Timer

I interfaced female headers with the 4×3 keypad, now it can be easily interfaced with the Arduino board.

About the i2c 16×2 LCD:

Countdown Timer

This is just a normal 16×2 LCD which is converted into an i2c supported type LCD by using the PCF8574 i2c Driver module. The four male headers are clearly labeled as GND, VCC, SDA, and SCL. A 10K variable resistor which is used for the adjustment of the LCD contrast.

I2c addresses:

Countdown Timer

As you can see the driver module is also provided with A0, A1, and A2 links which can be used to set the i2c address. As you can see no links are fitted the 7-bit address is 0x27 which you have to confirm in the datasheet, may be your LCD have a different i2c address. The links control the least significant 3 bits, fitting the link sets the bit low.


Countdown Timer Circuit Diagram:

Countdown Timer

As you can see the circuit diagram is really simple. All the 16 pins of the PCF8574 driver module are connected with the LCD pins. Using these connections you can convert any 16×2 LCD into an i2c supported LCD. The VCC pin is connected with the Arduino’s 5 volts, the SDA pin is connected with the Arduino’s Analog pin A4, the SCL pin is connected with the Arduino’s Analog pin A5, while the GND pin is connected with the Arduino’s ground.  Using only two pins A4 and A5 we can control the 16×2 LCD. You don’t need to purchase the 16×2 LCD and the PCF8574 driver module separately, you can purchase a readymade module, the purchase link is given above.

A 4×3 keypad is interfaced with the Arduino using the digital pins 4, 5, 6, 7, 8, 9, and 10. The 4×3 keypad rows are connected with 4, 5, 6, and 7. While the 4×3 keypad columns are connected with 8, 9, and 10. You can also use a 4×4 keypad leaving column 4 of the 4×4 keypad unconnected.

A one channel relay module is connected with the digital pin 13 of the Arduino. The relay used is of the type SPDT “Single Pole and Double Throw”. You can purchase a readymade relay module or you can follow the same exact connections and build the one by yourself.

Countdown Timer Proteus Simulation:

Before the actual wiring, I designed a simulation of the countdown timer in Proteus, which really helped me in completing my programming without physically connecting the Arduino and other components. Proteus is really powerful simulation software, especially for beginners. If you don’t have the components you can install a free version of the Proteus simulation software and make the simulation by yourself or you can download the simulation of the countdown timer given below.

Download Countdown Timer Proteus Simulation

Countdown Timer

I connected everything as per the circuit diagram which I already explained in very detail. In the simulation, you can see I have not connected the 10k resistor at the base of 2n2222, but in practical you must connect this resistor. So, after completing the connections the next step was to start the programming using the Arduino IDE.

Countdown Timer Arduino Code / Programming:



Countdown timer Arduino code explanation:

Before you start the programming, first of all, make sure you download the wire and LiquidCrystal_I2C libraries by clicking on the link given below:

Download Libraries

Maximum of the code used in the project, I have already explained in my previous tutorial which was based on the Password Door Lock Security System using Arduino and Keypad. So, if you find the programming a bit complex you can read the above article.

The new things that I added in this project are the 16×2 i2c LCD and the millis() function. for counting the seconds I used the millis() function. So this countdown timer is actually based on the millis() function.

Running the Countdown Timer simulation:

Once, I was done with the programming, I simply compiled the program and generated the Hex file link. If you are not able to see the Hex file link then flow the steps given below.

Click on the File Menu and select preferences.

Countdown Timer

This will open the preference window. Make sure you check the compilation and upload boxes and then click on the Ok button.

Countdown Timer

Now to generate the Hex file simply click on the Verify button, and wait for a while. Once the program is compiled then you can copy the Hex link.

Countdown Timer

I selected the entire link, pressed ctrl + c on the keyboard to copy the link and then pasted this link into the Arduino Uno board in the Proteus simulation software.

While the countdown timer simulation is opened, double click on the Arduino Uno and paste the copied link into the program file text field.

Countdown Timer

That’s it.

To run the simulation I clicked on the play button. Initially, there were some logical errors, so after 2 hours of programming, I fixed everything. Each time I was doing any change in the Arduino programming, I was compiling the program to update the Hex file. Finally, everything worked the way I wanted. The following are the screenshots of the project in action. Initially when you run the simulation. You will be asked to enter the minutes.

Countdown Timer

Countdown Timer

I entered 1 minute using the keypad and pressed the Asterisks key on the keypad to complete my entry, you can add more minutes but make sure you press the Asterisks key at the end. After entering the minutes then I was asked to enter the seconds.

Countdown Timer

I entered 2 seconds and pressed the Asterisks key on the keypad. So the total entered time is 1 minute and 2 seconds. the minutes were converted into seconds. so on the LCD, the total time will be displayed in seconds which is 62 minutes. Initially, you can see the Load is OFF. So after entering the seconds and pressing the Asterisks key the timer started after 2 seconds and also turned ON the Load connected with the relay.

Countdown Timer

The timer started it turned ON the load, as you can see on the LCD, the total seconds remaining and the load status which shows that currently, the load is ON. Once the time was completed i.e the total seconds decremented to zero. The load status on the LCD change from load ON to load OFF and also the relay was turned OFF.

Countdown Timer

To start again, you can press on the Hash “#” key, and you can start again by entering the minutes and seconds. I checked it so many times and there were no bugs and malfunction. At this point, I was satisfied with all the connections and programming, and now I was ready for the practical connections.


Countdown Timer Final Look:

 

Countdown Timer

This is how the Countdown Timer looks after the final connections. All the components are interfaced as per the circuit diagram. It will look amazing if all the components are packed inside an enclosure. You can make the one using a 3d printer. Or purchase the readymade plastic enclosure.

The final step was to power up the Arduino, and one channel relay module using the 12 volts. I checked this project so many times and it worked perfectly. For the practical demonstration watch video tutorial given below.

Countdown Timer


Watch Video Tutorial:

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

3 Comments

  1. thanks for the project. i need to modify the the code. i must input seconds only, than a servo must do a sweep on the program must loop for the time input rotating the servo though an angle , then wait the input time and do it again till a button is press to reset and input a new time. i you can help i would really be very thank full as i need this to complete my enealing machine. the events will be input time, servo 1 does a sweep, timer swithes on the oscillator via relay, vervo does a sweep and then resets to start again with the time input.

  2. when i run the coding, this appear “Keypad.h: No such file or directory”
    how im going to solve this problem ????

Leave a Reply