This is my project of a digital clock with RTC (Real Time Clock) using a LED display of 4 digits and 7 segments including interesting features of temperature and humidity.
In the control of display I have used an Arduino Uno R3 and 02 ICs of 74HC595 (8 bit shift register with output latches).
The use of shift register is important to save output ports of Arduino and with it is necessary only 3 outputs of Arduino to control the display.
There are two breakouts: one for the sensor of temperature (ºC - Celsius / ºF - Fahrenheit degrees) and humidity (in %) and another one for the RTC (Real Time Clock).
The assembly is very simple, but is necessary to pay attention with the jumpers connections.2- Material List
- 1 x DS1307 (Real Time Clock)
- 1 x DHT11 (Temperature and Humidity sensor)
- 2 x 74HC595 (8 bit shift register with output latches - 3 state)
- 8 x Resistors of 150 Ohms (Brown, Green, Brown)
- 1 x FYQ-5642BX (Common Anode LED Display 04 digits and 07 segments or equivalent but take care with the pins numbers)
- 1 x Arduino Uno
- 1 x Breadboard
- 1 x Kit of jumpers
The assembly of components is very simple but you need to follow the schematics with care due to the wire connections. There are 2 shift registers in this project: one to control each segment of the display and another one to control what is the display on.
Important: If you want to use another kind of LED display, you need to check its datasheet in order to update the output wiring (jumpers) of 74HC595 and also you must update the corresponding logics of Arduino's software.4- Coding
The following binary data represent the relation between the digits (0 to 9) and the segments (A to G) of LED display:
- B01111110 - 0
- B00110000 - 1
- B01101101 - 2
- B01111001 - 3
- B00110011 - 4
- B01011011 - 5
- B01011111 - 6
- B01110000 - 7
- B01111111 - 8
- B01111011 - 9
To show in the LED display all the data in sequence for the time, temperature and humidity, I have used a "timer" with the functions millis() and while(). In this case, each information is presented on the display in sequence after 03 seconds of each one. Simple and very efficient.
You can apply this function millis() in several different ways to manage the time during the program running. In many situations you can use it in the place of some timer library.
Another usefull function is
digitalWrite() that can simplify the writting of data into the shift registers.
Take a look in the Arduino's home page.5- First adjustment of RTC module
1. To adjust the time of RTC module, load and run the program "
SetTime " (you can find it on the library/example of DS1307RTC on Arduino IDE).
2. Reload and run again the program of "Digital Clock".
Following this procedure, the RTC module will keep the right time due its battery pack attached and you do not need to recompile the "Digital Clock" program every time you use it.