Introduction: Digital Clock Using 7 Segment Display Controlled Using TV Remote
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.
In this project, I am going to produce a digital clock which uses 7 segment displays to display the time. Besides of using 7 segment displays, Liquid Crystal Display (LCD) is also used to allow feature selections and menu navigation purpose. I am using a popular platform, Arduino with Atmega328P as the microcontroller for this project. The clock information will be obtained from Real Time Clock (RTC) IC which is DS1307.
Besides of displaying the time, the digital clock in this project also have extra features such as alarm, thermometer, stopwatch and timer. Stopwatch and timer are actually functions usually available in watch but we try to integrate it together with digital clock. Another extra feature that are available in this project is that instead of using normal button for user interface, I used TV remote to control the functions of digital clock, this provides a wireless control.
If you want to see how this project works, go to step 11 for video.
Step 1: Hardware
I will list down most of the parts that are being used in this project and further explain each of them in detail later on.
Bill of materials:
- DIY Arduino Uno
- DS1307 Real Time Clock IC
- 3V Lithium Battery
- CR 2032 Batter Holder
- 74HC595 Shift Register
- Common Anode 7 Segment Display
- 2N3904 NPN Transistor
- LM 35 Temperature Sensor
- TSOP 4838 IR Receiver
- TV Remote
- 16x2 Liquid Crystal Display
Step 2: DIY Arduino Uno
In this project, Arduino Uno is used as the microcontroller to control all the inputs and outputs. Arduino Uno uses the microcontroller chip, Atmega 328P.
Some of the features of Arduino Uno:
• Operating Voltage: 5V
• Digital I/O Pins: 14 (6 provide PWM output)
• Analog Input Pins: 6
• Flash Memory: 32KB (Atmega 328P) of which 0.5KB is used by bootloader
• SRAM: 2KB (Atmega 328P)
• EEPROM: 1KB (Atmega 328P)
• Clock Speed: 16MHz
Instead of using the original Arduino Uno, I made myself my own Arduino Uno. The method is simple and there are a lot of guide on how to make your own Arduino and how to make your own PCB.
Step 3: DS1307 Real Time Clock
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.
The DS 1307 that I used has been made onto a DIY PCB with 3V Lithium Backup Battery. This allow easy use for variety of projects.
One of the benefits of using DS1307 is that it can be connected to a backup supply. A 3V, CR2032 Lithium battery is used as the backup supply for DS1307. Whenever the built in power sense detects power failures, it will switch to backup supply and continue the time keeping operation. In other words, the user no needs to worry the loss of time information even if the main controller is being switched off.
DS1307 is controlled using Inter- Integrated Circuit (I2C) communications. I2C uses only two bidirectional open drain line, which are Serial Data Line (SDA) and Serial Clock Line (SCK). Since the data and clock line are open drain, pull up resistor is required to ensure the logic system settle at expected logic level. Open drain output means that the device can drive its output low but cannot drive it high. SDA is used to transfer data between master and slave, while SCK is used to synchronize all the data transfer over I2C bus.
How to use DS 1307 with Arduino: http://iamzxlee.wordpress.com/2013/06/27/ds1307-real-time-clock-rtc/
Step 4: 7 Segment Display
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.
How to use 7 segment display with Arduino: http://iamzxlee.wordpress.com/2013/07/08/7-segment-display/
Step 5: 16x2 LCD
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.
How to use Liquid Crystal Display with Arduino: http://iamzxlee.wordpress.com/2013/07/05/liquid-crystal-display-lcd-hd-44780/
Step 6: 74HC595 Shift Register
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.
Step 7: TSOP 4838 IR Receiver
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.
Step 8: LM 35 Temperature Sensor
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 LM 35 with Arduino: http://iamzxlee.wordpress.com/2013/07/01/temperature-sensor-lm35/
Step 9: Schematic Diagram
The schematic diagram for this project. It includes the Standalone Arduino with all the other hardware.
Step 10: Project Explanation
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.
Step 11: Video
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.
Link of this project on my blog: http://iamzxlee.wordpress.com/2013/12/20/digital-clock-using-7-segment-display-with-tv-remote/
If your have any suggestions or questions, feel free to comment below. I will try my best to answer your question.