Recently I have made another digital clock as a mini project for my course, Microprocessor. If you are following my previous projects, you may noticed that I have made two digital alarm clocks before, one displayed on 7 Segment Display and the other displayed on Liquid Crystal Display. However in this projects, the digital clock combines both of the display. Another special feature in this project is that no buttons are used to control it, instead TV remote is used to control the clock wirelessly.
There are varieties of digital clock available in our daily life. Basic digital clock usually will have some built in features such as alarm clock, calendar, and thermometer besides display the clock information. Some of the advance digital clock also has features such as AM and FM radio. Most of the digital clocks are using LCD display.
You can have a look on the video how this digital clock works with explanations.
Next, let me briefly explain about the hardware used for this project.
Parts and materials used:
– DIY Arduino Uno
– DS 1307
– 3V Lithium Battery
– CR2032 Battery Holder
– 74HC595 Shift Register
– 2N3904 NPN Transistor
– Common Anode 7 Segment Display
– LM 35 Temperature Sensor
– TSOP 4838 IR Receiver
– TV Remote
– 16×2 LCD
To get the time and date information, I am using DS1307 I2C Real Time Clock from Maxim Integrated. The clock and calendar provides seconds, minutes, hours, day, date, year and month information. In this project, the SQW pin is used for counting purpose in functions such as timer and stopwatch. Check out DS1307 for more info.
In this project, the main clock will be displayed on 7 segment display. However, to allow the navigation and functions select from user, I used Liquid Crystal Display.I am using 4 bit mode to control the LCD to save the IO pins. In 4 bit mode, I only need to control the RS, Enable and 4 data bits line to send data and commands. However, to further reduce the number of pins used, I control the LCD through 74HC595 Shift Register.
For this project, six Common Anode 7 Segment Displays is used to display the time. This gives me six digits of display which will be used for hours, minutes and seconds. For a Common Anode display, the segment can be turned on by giving a LOW (0V) on particular segments.
Since there are 7 segment displays is used, a total of 48 pins is required to individually control each segments. The solution for this huge number of IO pins is by using 74HC595 Shift Register to expand for more output pins. In this case, two shift registers is used to control six digits of 7 Segment Displays.
First shift register has 8 output pins which are used to control each segments whereas second shift register is used to control the common pin of 7 segments display.
In order to overcome the outputs pins limitations from Arduino Uno, 74HC595 Shift Register is used. We only required three pins to control the shift register which is the Serial Data Input, Shift Register Clock Input and Storage Register Clock Input.
In this project, three 74HC595 is being used, one to control each segments of 7 segment display, second to control each digit of 7 segment display and third is to control the LCD display.
In this project, instead of using tact switches for user input, I used TSOP 4838 IR Receiver as input. This IR Receiver is used to receive from remote control of consumer electronics such as TV. The remote control transmit modulated IR signal at 38kHz, where the IR led is turned on and off to send information.
Different remote controls have their own IR remote protocol. Therefore, to ease the job of getting the information, I use the IRremote library from Ken Shirriff. I just need to decode the results from IR receiver and use it for specific function.
(Will make a tutorial on how to include IR Receiver in your project soon.)
Besides of having clock information, I have also include a function to display the surrounding temperature using LM35 Precision Centigrade Temperature Sensor. LM35 is calibrated in degree Celsius. LM35 is linear in +10mV for every degree increase, so the temperature can be obtained by converting from analog to digital value. How to use LM35.
Below are the schematic diagrams for this project:
A photo on how this project looks.
When the Arduino first power up, it will display time information on 7 segment displays. Besides that, the LCD will display the time, date, temperature and day of week information. Basically, this is the main part of the program. The program will keeps on read from the DS1307 to update the time information.
When the user pressed ‘menu’ button on the TV remote, the LCD will display the selection for menu function. The functions available are alarm, timer, stopwatch and settings. User can navigate through each function by the ‘+/-‘ button. Whenever the user decides a function, the user can press the ‘select’ to enter that particular function.
For the alarm function, the user can first set the alarm time. To set each value, the user can use the number button on the TV remote. User also has to set the ‘ON/OFF’ to either enable or disable the alarm. The alarm will be check every time the program reads from DS1307 whether the time matches. If the alarm time reaches, the buzzer will sounds repeatedly until the user press the TV remote to disable it.
For the timer function, the user first needs to set the countdown timing. Again, the user can set the timing by using the number button on TV remote. To start the countdown, ‘select’ button has to be pressed. The programs will countdown based on the time set until it reaches ‘00.00.00’. At this time, the buzzer will sounds indicate the time reached. In order to disable the buzzer, the user has to press the ‘menu’ button.
For the stopwatch function, the user just need to press the start button, then it will start count up. If the user presses the start button again, it will stop the counting. Basically, the start button is like a toggle switch to control the stopwatch function.
The final function is settings function, where the user can set the time, date and control LCD backlight. The user able to set the time and date, then it will write on the DS1307 chip. The program also allows the user to either turn on or off the LCD backlight. The purpose of adding is that the user can turn off the backlight when it is not needed and for energy saving.
Let me show you some of the photos of this project operation.
Hopefully this detailed information on digital clock helps you in building your own project. I really learnt a lot throughout this project, and I hope I still can further improve this digital clock and make it better.
If your have any suggestions or questions, feel free to comment below. I will try my best to answer your question.