Arduino Timer

15K5516

Intro: Arduino Timer

Hello everybody, This instructable is all about how to build a stopwatch/ Timer using Arduino.

Features of this Timer: (Check for more in depth details how to use these features in "Code/Sketch" section

1. You can set a target time for an event and also can set up an alarm/reminder.

2. You can check time taken for a particular event.

Caution: This set up has no facility for counting laps. Any event can be pursued only for one lap.

One pitfall of this Timer is ---- Minimun Target time cannot be set less than 3minutes. Interested people can change the code and use as per they wish.

STEP 1: Required Materials

Arduino UNO (INR 1500/-)

LCD display(INR 225/-)

A switch

10Kohm Pot

2 1K ohm Resistors

1 pushbutton

few male to male jumper wires

few female to male jumper wires

Arduino Libraries:

StopWatch (provided in the "Code/Sketch" section)

Liquid Crystal(in-built in Arduino)

STEP 2: Circuit

There is nothing much new in the circuitary. Everything that you need to work on to build a timer is in the code. People who might have already worked on using LCD, can finish up the connections pretty easily. LCD Connections to the arduino board are the same and additionally use the switch and push buttons to connect to the digital pins.

Anyways for beginners, i had attached the circuitary for reference. Feel free to contact if there are any queries.

STEP 3: Code/Sketch

For the code, I used two libraries. One is the built in "LiquidCrystal" library and second is the "StopWatch" library. Stop Watch library files (.h and .cpp) are available in the Arduino blog page. I had attached the files for easy access.

In fact, this stop watch library made my work easy as i was intending to built a timer displaying the running time. If you wanted to built in a similar way, you need to use this library.

Copy the program in "Timer.dat" into your Arduino IDE file (.ino)

--------------------------------------------------------------------------------------------------------------------------------------------------

How to use the Timer:

This program works in two ways:

1. Set a target time for any event you are working:

For this you need to call the "reverse" routine in the loop fuction and you have been provided a facility to set a time for the event you are planning. check the "limit" input in the code.

2. Check how much time does an event takes:

For this you need to call the "start" routine in the loop function. No other inputs are required for this routine. Just press the switch and you are there.

You can also add a 8ohm speaker to this set up. Assign a digital output and use an if statement to work out.

STEP 4: Conclusion

This program can be improvised by adding lap count facility. If in case anyone, who is also a beginner like me, out there need any help in understanding the library or code, feel free to contact.

Thanks for Reading.

12 Comments

can we use oled instead of lcd
How could I used that codes???

i mean where can i connect the indication bulb and suggest me a modification in program to switch of its supply after time runs out

where do u take the output from the circuit.......is there any indication like a bulb or something to off after the time runs out

sir, can you guide me towards making such a timer .Like,some facts on how to start

sir,in my project of smart sprinkler ,the sprinkler should automatically get on for a set duration(for ex- if i set the timer on for 5-6 am everyday the sprinkler should get on automatically on the assigned days.)So, can it be done using this project or i have to separetely use a RTC(real time clock module for arduino.)??

Yes, you need a RTC clock because this prototype works as a stop watch.

Hi thanks for the tutorials. I have a doubt is it possible to set the time manually from my push button instead of keeping it to a constant 3 mints. what modification i need to make?

Thank you. You can use "pulseIn" function to do your job. Have a look at the reference below. Hold on the push button as per your wish and use the return value multipled by 60 to desired number of minutes and use it in the "limit" label of the code. Let me know if you have any queries.

https://www.arduino.cc/en/Reference/PulseIn

Hi can you tell me please, what are the switches do (especially switch 2 because I can't udnerstand its connection also) and is the pot for dimming the light of the lcd?

1. There are two kinds of switches that I used here. Switch 1 is like power switch which you like your fan switch or light switch. Where as Switch 2 is pushbutton, current passes through it only when you hold on the button, when you remove circuit is open.

Regarding the connections, There are three connections here for switch 2. 5V to Switch 2 via a 1k resistor, Ground and a connection to digital pin 4. Let me know if you face any problem with respect to connections.

2. yes, potentiometer application over here is to change the contrast of the display.

thank you very much now is more clear to me, i would call switch 2 a button with a pull up resistor respectively to 5v. Thank you for your reply.