Digital Clock RTC With LED Display of 4 Digits and 7 Segments

43,185

61

55

Posted in TechnologyClocks

Introduction: Digital Clock RTC With LED Display of 4 Digits and 7 Segments

About: I'm a Mechanical Engineer and an enthusiastic Maker. I like to create and code my projects using the Arduino.

Hello, everybody!


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. You only need 3 outputs to control the display. With it you transfer serial data into 8 parallel outputs.

There are two breakouts: one for the sensor of temperature (ºC - Celsius / ºF - Fahrenheit degrees) and humidity (% - in percentage) and another one for the RTC.

The assembly is very simple and you just need take care with the wiring. Be patient, follow the schematics and enjoy it.

(See VIDEO)

Note: Code updated to revision V1.3 in Oct.2017


- Introduction of the colon (double dot) flicking in the hours.

- Introduction of brightness control in the code.

Step 1: Material

Material list:

- 01 x DS1307 (Real Time Clock)

- 01 x DHT11 (Temperature and Humidity sensor)

- 02 x 74HC595 (8 bit shift register with output latches - 3 state)

- 08 x Resistors of 150 Ohms (Brown, Green, Brown)

- 01 x FYQ-5642BX (Common Anode LED Display 04 digits and 07 segments or equivalent but take care with the pins numbers)

- 01 x Arduino Uno

- 01 x Breadboard

- 01 x Kit of jumpers

Step 2: Assembly

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.

Step 3: Programming

To run the program on Arduino you need to have the following libraries:

  1. Time (library for date & time)
  2. DS130RTC(library for the Real Time Clock)
  3. Wire (library used to support the RTC)
  4. DHT_Sensor_Libray (Adafruit's library for DHT sensor of Temperature and Humidity)

For the numbering (0 to 9), I have created a table with binary representation of each segment (A to G) that forms the digit as following:

  • 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 the data in sequence of time, temperature and humidity, I have used a "timer" with functions millis() and while().

In this case, each information is presented on the display and after 3 seconds moves to the next 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(). With this function you can simplify the writting of data into the shift registers.

Take a look on it in the Arduino's home page at http://arduino.cc/en/Reference/DigitalWrite

- How to setup the time of internal clock of RTC module:

1. To update or setup 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.

6 People Made This Project!

Recommendations

  • Microcontroller Contest

    Microcontroller Contest
  • Woodworking Contest

    Woodworking Contest
  • Casting Contest

    Casting Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

Sir, Can you provide me the arduino code for this digital clock ???

I want to make it, but I don't no how to program properly.

55 Comments

you have said that you have published another project to set time with push button can you plz share the website link

i need to add led for blinking but if i add blink code in loop ,seven segment switches off when led goes on and if led goes off segment lights on how can i solve this?

Try to update for the following statements:

hora=hour() %12;

if (hora==0) {

hora=12;

}

Probably is a circuit issue. Check the connections and also check individually all LEDs of the display with failure.

thanks for great instructable

in my case dots are not working ...whats the problem?

1 reply

Shivam gautam,

Probably the LED display is not exactly the same of this project.

You need to check the electrical diagram of your display and try to identify what pin controls the colon / dots.

Please provide straight forward circuit diagram of the project and how to get following libraries "


  1. Time (library for date & time)
  2. DS130RTC(library for the Real Time Clock)
  3. Wire (library used to support the RTC)
  4. dht11 (library for the sensor of Temperature and Humidity)"In which directory to be kept all these directory so that main program can be downloaded without error. My self hobbyist and want to build this clock circuit

What if i using 4 one digit 7segment display?

1 reply

You can do it replicating same wiring connections of 4 digits 7 segment display.

technical question : no way to change the 8 protection resistances with only 4 connected to commun anode pins ?

1 reply

Good question! I had this concern too!

When you make some electronic circuit you must know all technical limitations of the components you are using and the basis of these information are in their datasheets.

In my project, all segments of LED display are limited by their maximum current and so they are protected by individual resistors.

If you connect the resistors only to common pins, you need to consider the maximum current when all 7 segments will be on.

In this case it can works well with only 1 resistor, but the brightness of that segment will be lower.

Another point you need to consider is the limit of each port of -595- shift register.

I want ask if it's possible to add simple if routine that verify if the hour decimal number is 0 (B01111110) then he no display it ...

2 replies

make it ... too easy ... :

if (dezenaHora != 0) {

digitalWrite(latchPin, LOW);

shiftOut(dataPin, clockPin, LSBFIRST, 8); //Set DISPLAY 1 (top view from left to right)

shiftOut(dataPin, clockPin, LSBFIRST, ~num[dezenaHora]); //Set the Hour (ten)

digitalWrite(latchPin, HIGH);

}

I think I love arduino :)

The power of the Arduino comes from the code you make. ;-)

I mam beginner with AURDINO . Thank All

Hello sir!

I am new to Arduino and I've been trying to do this same project but I have encountered several problems of which, some I have been able to solve and others not ... So I turn to your help to see if I can finish it!

sketch_jun14e:6: error: expected unqualified-id before numeric constant

#define DHT11 11 //Define al pin 11 como sensor DHT11

^

C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino:7:1: note: in expansion of macro 'DHT11'

DHT11 DHT; //Define el nombre DHT al sensor de temperatura y humedad

^

C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino: In function 'void loop()':

C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino:83:53: warning: large integer implicitly truncated to unsigned type [-Woverflow]

shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Configura los LEDs de los doble puntos

^

sketch_jun14e:94: error: expected primary-expression before '.' token

chk = DHT.read(DHT11_PIN); //Lee la data del sensor DHT11

^

sketch_jun14e:94: error: 'DHT11_PIN' was not declared in this scope

chk = DHT.read(DHT11_PIN); //Lee la data del sensor DHT11

^

sketch_jun14e:97: error: expected primary-expression before '.' token

temp = DHT.temperature; //Lee la temperatura en grados centígrados (ºC)

^

sketch_jun14e:132: error: expected primary-expression before '.' token

umid = DHT.humidity; //Lectura de humedad

^

exit status 1

expected unqualified-id before numeric constant


(I'm using Arduino Mega with all the bookstores mentioned ...)


By another way, I wanted to ask if you could add 2 pushbuttons to "set" the time, for example every time you press a button add +1 hour and the other that adds +1 minute.


First of all, thanks for your help! greetings from Argentina

1 reply

Hello, TanoT2,

Thank you to try to replicate this project.

I have some comments:

1) I see you have done some changes in the original code.

2) Did you try to run my original code?

3) Did you see any errors after compilation of original code?

3) In your version of code, you need to fix the following declaration:

#define DHT11_PIN 11 //Sensor DHT11 conected to the pin 11 on Arduino

Pls, try again and keep me informed.

Saudações do Brasil,

LAGSILVA