loading

Hello, all !!

This is my project of a digital clock with RTC (Real Time Clock) using a LED display of 04 digits and 07 segments including features of temperature and humidity.

To control the display I have used an Arduino Uno and 02 chips 74HC595 (8 bit shift register with output latches).

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

The assembly is very simple but you need take care with the wiring.

Be patient, follow the schematics and enjoy it.

(See VIDEO)

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 easy but you need to follow the schematics with care about the wiring connections.

If you want to use another LED display, check the datasheet to update the output wiring (jumpers) of 74HC595.

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. dht11 (library for the 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 the program "SetTime" that you can find here or in the library/example of DS1307RTC on Arduino Software.

2 - Recompile and reload the program of Digital_Clock on Arduino.

With 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 turn it on.

Step 4: Conclusion

The main lesson for me in this project is related to the logic to manage the display (data multiplexing) using shift registers and also the combination of different sensors in same application.

I hope you have enjoyed this project where I also had the opportunity to contribute to you with a little bit more information about Arduino programming.

Best regards.

LAGSILVA

March 22, 2015

(Last update: 17.Jun.2017)

<p>Display CC (FYQ-5642AX/)?</p>
<p>Hello,</p><p>Sorry for my delay to answer you and thank you for your question. <br></p><p>This information was missing and I will update it on Instructables.</p><p>The display is CA as you can see in the image below.</p><p>The code number of display is just for reference but you can use another similar one.</p><p>Regards,</p><p>Lu&iacute;s Antonio</p>
<p>I mam beginner with AURDINO . Thank All</p>
<p>Hello sir! </p><p>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! </p><p>sketch_jun14e:6: error: expected unqualified-id before numeric constant</p><p> #define DHT11 11 //Define al pin 11 como sensor DHT11</p><p> ^</p><p>C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino:7:1: note: in expansion of macro 'DHT11'</p><p> DHT11 DHT; //Define el nombre DHT al sensor de temperatura y humedad</p><p> ^</p><p>C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino: In function 'void loop()':</p><p>C:\Users\Cejas\Desktop\sketch_jun14e\sketch_jun14e.ino:83:53: warning: large integer implicitly truncated to unsigned type [-Woverflow]</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Configura los LEDs de los doble puntos</p><p> ^</p><p>sketch_jun14e:94: error: expected primary-expression before '.' token</p><p> chk = DHT.read(DHT11_PIN); //Lee la data del sensor DHT11</p><p> ^</p><p>sketch_jun14e:94: error: 'DHT11_PIN' was not declared in this scope</p><p> chk = DHT.read(DHT11_PIN); //Lee la data del sensor DHT11</p><p> ^</p><p>sketch_jun14e:97: error: expected primary-expression before '.' token</p><p> temp = DHT.temperature; //Lee la temperatura en grados cent&Atilde;&shy;grados (&Acirc;&ordm;C)</p><p> ^</p><p>sketch_jun14e:132: error: expected primary-expression before '.' token</p><p> umid = DHT.humidity; //Lectura de humedad</p><p> ^</p><p>exit status 1</p><p>expected unqualified-id before numeric constant</p><p><br>(I'm using Arduino Mega with all the bookstores mentioned ...) </p><p><br>By another way, I wanted to ask if you could add 2 pushbuttons to &quot;set&quot; the time, for example every time you press a button add +1 hour and the other that adds +1 minute. </p><p><br>First of all, thanks for your help! greetings from Argentina</p>
<p>Hello, TanoT2,</p><p>Thank you to try to replicate this project.</p><p>I have some comments:</p><p>1) I see you have done some changes in the original code.</p><p>2) Did you try to run my original code? </p><p>3) Did you see any errors after compilation of original code?</p><p>3) In your version of code, you need to fix the following declaration:</p><p>#define DHT11_PIN 11 //Sensor DHT11 conected to the pin 11 on Arduino</p><p>Pls, try again and keep me informed.</p><p>Sauda&ccedil;&otilde;es do Brasil,</p><p>LAGSILVA</p>
<p>Hello again!</p><p>Yes, I tried with the original code and this was the error: (also want to say that I tried to copy all the code and execute it in a new file and the same thing...)</p><p>Arduino:1.8.2 (Windows 7), Tarjeta:&quot;Arduino Mega ADK&quot;</p><p>sketch_jun15a:16: error: 'dht11' does not name a type</p><p>dht11 DHT; //Define the name DHT for the sensor of Temperature and Humidity</p><p>C:\Users\Cejas\Desktop\sketch_jun15a\sketch_jun15a.ino: In function 'void loop()':</p><p>C:\Users\Cejas\Desktop\sketch_jun15a\sketch_jun15a.ino:92:53: warning: large integer implicitly truncated to unsigned type [-Woverflow]</p><p>shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Set LEDs of double dots</p><p>sketch_jun15a:102: error: expected primary-expression before '.' token</p><p>chk = DHT.read(DHT11_PIN); //Read data of sensor DHT11</p><p>sketch_jun15a:105: error: expected primary-expression before '.' token</p><p>temp = DHT.temperature; //Reading the Temperature in Celsius degree (&Acirc;&ordm;C)</p><p>sketch_jun15a:152: error: expected primary-expression before '.' token</p><p>umid = DHT.humidity; //Reading the Humidity</p><p>exit status 1</p><p>'dht11' does not name a type</p><p>I tried with different libraries of the dht11 on the internet, and if you compare them, they are differen .... I used this one: <a href="https://github.com/adafruit/DHT-sensor-library" rel="nofollow">https://github.com/adafruit/DHT-sensor-library</a></p><p>AND I had to rename the DHT.h and DHT.cpp to dht11.h and dht11.cpp to &quot;fix&quot; the error:<br>no such a file or directory error</p><p>#include &lt;dht11.h&gt; // Temperature and Humidity Library</p><p>Im confused...</p>
<p>Hello Tano T2,</p><p>If you use another library you must update the main code to use the correspondent statements of new library.</p><p>Libraries sometime are updated by their authors and an older code that use them must be updated too. Maybe this is the case here and I need to update my code for current versions of DHT libraries, but I won't do it for now.</p><p>Anyway I included at Step 3 of this Instructable the DHT11 library I have used when I developed this project.</p><p>Please, try to download and install it in your Arduino IDE and tell me if finally it works.</p><p>Regards,</p><p>LAGSILVA</p>
<p>ALMOST DONE!!</p><p>Finally worked! Only shows me an error with double points:</p><p>In function 'void loop()':</p><p>warning: large integer implicitly truncated to unsigned type [-Woverflow]</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000);</p><p>And both, the temperature and humidity indicates 0 &deg; C and 0% ... I'm using a DHT22, is it compatible?</p>
<p>Hello Tano T2,</p><p>There are some differences between DHT11 and DHT22. This last one is more accurated.</p><p>I have updated my code to use DHT library of Adafruit that can be used for both types of sensor.</p><p>Try download it and set the code according to the sensor version you are using in the following statements:</p><p>//#define DHTTYPE DHT11 // DHT 11</p><p>#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321</p><p>//#define DHTTYPE DHT21 // DHT 21 (AM2301)</p><p>Please, inform me about the results.</p><p>Regards,</p><p>LAGSILVA</p>
<p>Tano T2,</p><p>Great news !!</p><p>I do not see this warning message in my Arduino IDE. Maybe the code will run because it is not an error, but the root cause must be investigated.</p><p>Probably the indication of 0&ordm;C and 0% is because the data of DHT was not read correctly.</p><p>As I told you, the main code must be updated to use more recent libraries of DHT.</p><p>Try investigate about differences between DHT22 and DHT11 and keep me informed about your progress. From my side I will do it too.</p><p><strong>Note</strong>: I think all this road blocks are very good for everyone learn more and more. Investigation, tryouts and learning are part of the maker world. Go ahead, be patient and be curious all the time!</p><p>Regards,</p><p>LAGSILVA</p>
<p>i had some erros in coding. please help me clear this..</p>
<p>Did you add all libraries into your Arduino's IDE ?</p><p>You need install all the followings libraries before compile the code:</p><p> &lt;Time.h&gt; : Time Library</p><p>&lt;DS1307RTC.h&gt; : Real Time Clock Library</p><p>&lt;Wire.h&gt; : Wire Library</p><p>&lt;dht11.h&gt; : Temperature and Humidity Library</p>
yes, i was added the all libraries. <br>but still this error will be came again and again,,!
<p>Hello Amarnath,</p><p>I have added in Step 3 of this Instructable the DHT11 library I have used when I developed this project.</p><p>Please, try install it in your Arduino IDE and tell me if it finally works.</p><p>Regards,</p><p>LAGSILVA</p>
<p>1) Check the directories structures of libraries in your Arduino installation. Probably the compiler is not finding the <strong>dht11 </strong>library.</p><p>2) Try Google &quot;arduino error does not name a type&quot;. I found many solutions for this error. Maybe one of them can fix it.</p>
<p>Great work! I built my own version in an hour and your code worked perfectly.</p><p>I have one small issue though. I'm using two 2-digit displays instead of one 4-digit, so I don't have the central dots between hour and minute. Instead, a single decimal point lights for the second digit. I guess this is set by this part of the code:</p><p>shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Set LEDs of double dots</p><p>Is there any way to also make the decimal point for digit to also light at this time? That way I can rotate my second 2-digit display by 180 degrees to recreate the double dots.</p>
<p>Grrrmachine,</p><p>Thank you very much!!</p><p>Please, post a photo of your project here.</p><p>If your display are with the LEDs not inclined some degrees, I think it is feasible to put one of them upside down. If not, the result could be a little bit strange due to the different angles of inclination of both displays when you rotate one of them by 180 degrees.</p><p>The logic of sequence to control the LED of the displays of my project is:</p><p><strong>Dot - A - B - C - D - E - F - G</strong></p><p>For your project you must consider the transfer function for the 2nd. display:</p><p><strong>Dot - E - F - G - A - B - C - D</strong></p><p>I see you have two ways to apply this logic:</p><p>1) Change wire connection of 2nd display according with 2nd sequence.</p><p>2) Create a second <strong>byte num2[ ] </strong>with new sequence to be applied in the 2nd display and update the code (in this case you can mantain same wiring connection of original project).</p><p>//Digits Matrix - 0 to 9 - <strong style="">For 1ST. Display</strong></p><p>byte <strong>num1</strong>[] = {</p><p> B01111110, // Zero</p><p> B00110000, // One</p><p> B01101101, // Two</p><p> B01111001, // Three</p><p> B00110011, // Four</p><p> B01011011, // Five</p><p> B01011111, // Six</p><p> B01110000, // Seven</p><p> B01111111, // Eight</p><p> B01111011, // Nine</p><p>};</p><p>//Digits Matrix - 0 to 9 - <strong>For 2ND. Display</strong></p><p>byte <strong>num2</strong>[] = {</p><p>B01101111, // </p><p>B00000110, // </p><p>B01011101, // </p><p>B00011111, // </p><p>B00110110, // </p><p>B00111011, // </p><p>B01111011, // </p><p>B00001110, // </p><p>B01111111, // </p><p>B00111111, // </p><p>};</p><p>Good luck and keep me posted on your progress!</p><p>Regards,</p><p>LAGSILVA</p><table><br> </table>
<p>Sir Lagsilva i have a question, can i not include the sensor temperature and humidity sensor?.... Will it affect the circuit or not?.. Thank you</p>
<p>Hello, Ed Marsjosef,</p><p>I am understanding you want only the clock function running, without the temperature and humidity information been displayed.</p><p>Yes, you can delete the sensor and the circuit will be not affected.</p><p>Without the sensor, the code will consider as 0 (zero) the values of temperature and humidity.</p><p>Regards,</p><p>LAGSILVA</p>
<p>Thank you sir</p>
<p>Hi Lagsilva, </p><p>I really enjoy your projects and can tell you are a real enthusiast by the way you respond to fellow builders especially beginners like myself! I'll be following your builds with interest. You have a real talent for explaining things and should do some full build videos which I'm sure would be popular! Keep the projects coming! </p><p>Davy</p>
<p>Hello, Davy,</p><p>Thank you very much for your feedback!</p><p>I am not a specialist, I am really an enthusiast of this technology that help us to learn more, to be curious, to be inventive, to be better than yesterday!</p><p>Everyone is a beginner in something because we do not know everything. </p><p>But we can learn!! All the time!</p><p>Regards,</p><p>Lu&iacute;s</p>
It's your enthusiasm that shines through! Keep it up! ;-)<br>
<p>Hello.</p><p>Thank you so mutch for a great idea. :-)<br>Bought the parts yesterday, and assembled today.</p><p>BUT, i get this errorcode trying to verify the script. </p><p>Could you help?</p><p>______________________</p><p>In file included from C:\Users\arnes\Downloads\Digital_Clock_V1_English\Digital_Clock_V1_English.ino:13:0:</p><p>C:\Users\arnes\Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:19:22: error: 'tmElements_t' has not been declared</p><p>static bool read(tmElements_t &amp;tm);</p><p>^</p><p>C:\Users\arnes\Documents\Arduino\libraries\DS1307RTC/DS1307RTC.h:20:23: error: 'tmElements_t' has not been declared</p><p>static bool write(tmElements_t &amp;tm);</p><p>^</p><p>Digital_Clock_V1_English:16: error: 'dht11' does not name a type</p><p>dht11 DHT; //Define the name DHT for the sensor of Temperature and Humidity</p><p>^</p><p>C:\Users\arnes\Downloads\Digital_Clock_V1_English\Digital_Clock_V1_English.ino: In function 'void setup()':</p><p>Digital_Clock_V1_English:50: error: 'setSyncProvider' was not declared in this scope</p><p>setSyncProvider(RTC.get); // Update the time with data of RTC (Real Time Clock)</p><p>^</p><p>C:\Users\arnes\Downloads\Digital_Clock_V1_English\Digital_Clock_V1_English.ino: In function 'void loop()':</p><p>Digital_Clock_V1_English:63: error: 'hour' was not declared in this scope</p><p>hora = hour();</p><p>^</p><p>Digital_Clock_V1_English:64: error: 'minute' was not declared in this scope</p><p>minuto = minute();</p><p>^</p><p>C:\Users\arnes\Downloads\Digital_Clock_V1_English\Digital_Clock_V1_English.ino:92:53: warning: large integer implicitly truncated to unsigned type [-Woverflow]</p><p>shiftOut(dataPin, clockPin, LSBFIRST, ~B10000000); //Set LEDs of double dots</p><p>^</p><p>Digital_Clock_V1_English:102: error: 'DHT' was not declared in this scope</p><p>chk = DHT.read(DHT11_PIN); //Read data of sensor DHT11</p><p>^</p><p>exit status 1</p><p>'dht11' does not name a type</p>
<p>Hello, Veigrillen,</p><p>Thank you !! I hope you have success with this project.</p><p>It sounds me there is some missing library.</p><p>Did you install the following libraries into your Arduino folder ?</p><ol><br><li>Time (library for date &amp; time)<li>DS130RTC (library for the Real Time Clock)<li>Wire (library used to support the RTC)<li>dhtt11 (library for the sensor of Temperature and Humidity)</ol><p>If you have done that, please try the following:</p><p>1) Download again the file &quot;Digital_Clock_V1_English.ino&quot;.</p><p>2) Open it on a word editor (WordPad, for example) and copy all the text.</p><p>3) Create a new file on Arduino Software.</p><p>4) Clean all the statements of new file and paste the text you have cop&iacute;ed on item #2.</p><p>5) Recompile the program and inform me the results.</p><p>Good luck!!</p>
<p>Thank you so mutch. :)<br>I finally got rid of the error codes, but encountered another problem.</p><p>I got the wrong RTC module. I got an DS3231N, and not the DS1307, so im not able to complete the &quot;mission. </p><p>Unless there is an easy workaround?</p><p>Thanks again.</p>
<p>Good news, Veigrillen !!</p><p>I do not see any issue if you use the DS3231 RTC. </p><p>Both modules use I2C bus and you can apply same library.</p><p>In fact the DS3231 is much more accurate than DS1307 !!</p><p>Just take care with corresponding connections SDA, SCL, Vcc and GND.</p><p>Take a look on this tutorial:</p><p><a href="http://tronixstuff.com/2014/12/01/tutorial-using-ds1307-and-ds3231-real-time-clock-modules-with-arduino/">http://tronixstuff.com/2014/12/01/tutorial-using-d...</a></p><p>Let me know about your tests.</p>
<p>Well, i got everything uploaded, and my led lights up, but i recon theres something wrong.. :)</p><p><a href="https://youtu.be/FXtVAHPSeSc" rel="nofollow">https://youtu.be/FXtVAHPSeSc</a></p>
<p>Hello, Veigrillen,</p><p>Any progress ?</p><p>Did you revise the connections and find out what is the issue ?</p>
<p>Uhm,, im a complete newbie, and didnt know that i could just reverse the connectors, so I just ordered a new led display with Common Anode. (They havnt arrived yet)</p><p>I feel kinda stupid now ;-)</p><p>Do you know if there is a &quot;walkthroug&quot; to reverse them?</p><p>Right now i got an SMA420564 display</p><p>Thanks in advance </p>
<p>Yes, it is possible to use a Common Cathode display, but you need to update all instructions of the program.</p><p>With right programming, you can control this hardware as you want!</p><p>For example, the following statements to set the Display #1 must be updated.</p><p><strong>From:</strong></p><p>digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, 8); //Set DISPLAY 1 </p><p> shiftOut(dataPin, clockPin, LSBFIRST, <strong>~</strong>num[dezenaHora]); //Set the Hour </p><p> digitalWrite(latchPin, HIGH);</p><p><strong>To:</strong></p><p>digitalWrite(latchPin, LOW);</p><p>shiftOut(dataPin, clockPin, LSBFIRST, <strong>~</strong>8); //Set DISPLAY 1 </p><p>shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaHora]); //Set the Hour </p><p>digitalWrite(latchPin, HIGH);</p><p>The sign <strong>~ </strong>inverts the signal from HIGH to LOW or vice versa.</p><p>Try to update all statements related to setup of the digits of display.</p>
<p>Hi buddy, and thanks for taking the time to help me.</p><p>Your last post really helped, and Im almost there..</p><p>Three of the four digits are working almost perfect, </p><p>As you can se of the video, there are some issues, and i'we gone over the connectors and cables, and all seem to be correct.</p><p><a href="https://youtu.be/6ZX0xNYYdic" rel="nofollow">https://youtu.be/6ZX0xNYYdic</a></p><p>Here is the code that i'we used:</p><p>/* Digital Clock</p><p> Digital Clock with LED Display - 4 Digits x 7 Segments</p><p> Display Time, Temperature and Relative Humidity</p><p> V1.1 - 10.Fev.2016</p><p> *** Notes of revision V1.1 *** </p><p> - Translated the remarks/comments into English</p><p> - Added optional statements to show the Temperature in Fahrenheit Degrees (&ordm;F)</p><p>*/</p><p>#include &lt;Time.h&gt; //Time Library</p><p>#include &lt;DS1307RTC.h&gt; //Real Time Clock Library</p><p>#include &lt;Wire.h&gt; //Auxiliary Library for DS1307RTC (Real-Time Clock) - Pins to Arduino UNO: A4 (SDA), A5 (SCL)</p><p>#include &lt;dht11.h&gt; //Temperature and Humidity Library</p><p>dht11 DHT; //Define the name DHT for the sensor of Temperature and Humidity</p><p>#define DHT11_PIN 11 //Sensor DHT11 conected to the pin 11 on Arduino</p><p>int clockPin = 8; // Pin 8 of Arduino connected in the pin 11 of 74HC595 (Clock)</p><p>int latchPin = 9; // Pin 9 of Arduino connected in the pin 12 of 74HC595 (Latch)</p><p>int dataPin = 10; // Pin 10 of Arduino connected in the pin 14 of 74HC595 (Data)</p><p>int hora, minuto, temp, umid;</p><p>int unidadeHora, unidadeMinuto, dezenaHora, dezenaMinuto;</p><p>int unidadeTemp, dezenaTemp, unidadeUmid, dezenaUmid;</p><p>unsigned long ti;</p><p>int chk; //Variable to read the sensor DHT11</p><p>//Digits Matrix - 0 a 9</p><p>byte num[] = {</p><p> B01111110, // Zero</p><p> B00110000, // One</p><p> B01101101, // Two</p><p> B01111001, // Three</p><p> B00110011, // Four</p><p> B01011011, // Five</p><p> B01011111, // Six</p><p> B01110000, // Seven</p><p> B01111111, // Eight</p><p> B01111011, // Nine</p><p>};</p><p>void setup() {</p><p> pinMode(latchPin, OUTPUT); // Define the 3 digital pins as output</p><p> pinMode(clockPin, OUTPUT);</p><p> pinMode(dataPin, OUTPUT);</p><p> setSyncProvider(RTC.get); // Update the time with data of RTC (Real Time Clock)</p><p> //setTime(15, 05, 00, 13, 02, 2016);</p><p>}</p><p>void loop() {</p><p> ti = millis(); // Initial time for the Timer of Hour/Time</p><p> while ((millis() - ti) &lt; 3000) { //Timer of 3 seconds to show the Hour</p><p> hora = hour();</p><p> minuto = minute();</p><p> unidadeHora = hora % 10;</p><p> dezenaHora = hora / 10;</p><p> unidadeMinuto = minuto % 10;</p><p> dezenaMinuto = minuto / 10;</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~8); //Set DISPLAY 1 (top view from left to right)</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaHora]); //Set the Hour (ten)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~4); //Set DISPLAY 2</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeHora]); //Set the Hour (unit)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~2); //Set DISPLAY 3</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaMinuto]); //Set the Minute (ten)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set DISPLAY 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeMinuto]); //Set the Minute (unit)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~4); //Set LED of dots</p><p> shiftOut(dataPin, clockPin, LSBFIRST, B10000000); //Set LEDs of double dots</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set DISPLAY 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, 255); //Reset the DISPLAY 4 (to avoid some flicking)</p><p> digitalWrite(latchPin, HIGH);</p><p> }</p><p> delay(500); //Wait for half second before go ahead to show the next feature</p><p> chk = DHT.read(DHT11_PIN); //Read data of sensor DHT11</p><p> ti = millis(); //Initial time for the Timer of Temperature</p><p> temp = DHT.temperature; //Reading the Temperature in Celsius degree (&ordm;C)</p><p> //Optional calculation of Temperature in Fahrenheit degrees (&ordm;F). Remove the comments (&quot;//&quot;) of following statement to use it.</p><p> //temp = (temp*18+5)/10+32; </p><p> while ((millis() - ti) &lt; 3000) { //Timer of 3 seconds for the Temperature</p><p> unidadeTemp = temp % 10;</p><p> dezenaTemp = temp / 10;</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~8); //Set DISPLAY 1 (top view from left to right)</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaTemp]); //Set the Temperature (ten)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~4); //Set DISPLAY 2</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeTemp]); //Set the Temperature (unit)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~2); //Set DISPLAY 3</p><p> shiftOut(dataPin, clockPin, LSBFIRST, B01100011); //Set the degree symbol [&ordm;]</p><p> digitalWrite(latchPin, HIGH);</p><p> //Show the Temperature in Celsius degrees (&ordm;C)</p><p> //Set the following statements as comments with &quot;//&quot; to show the Temperature in Fahrenheit (&ordm;F)</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set DISPLAY 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, B01001110); //Set the symbol of Celsius [C]</p><p> digitalWrite(latchPin, HIGH);</p><p> //Show the Temperature in Fahrenheit degrees (&ordm;F)</p><p> //Remove the indication of comments &quot;//&quot; on following statements to show the Temperature in Fahrenheit (&ordm;F) </p><p> //digitalWrite(latchPin, LOW);</p><p> //shiftOut(dataPin, clockPin, LSBFIRST, 1); //Set DISPLAY 4</p><p> //shiftOut(dataPin, clockPin, LSBFIRST, ~B01000111); //Set the symbol of Fahrenheit [F]</p><p> //digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set DISPLAY 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, 255); //Reset the DISPLAY 4 (to avoid some flicking)</p><p> digitalWrite(latchPin, HIGH);</p><p> }</p><p> delay(500); //Wait for half second before go ahead to show the next feature</p><p> ti = millis(); //Initial time for the Timer of Humidity</p><p> umid = DHT.humidity; //Reading the Humidity</p><p> while ((millis() - ti) &lt; 3000) { //Timer of 3 seconds for the Humidity</p><p> unidadeUmid = umid % 10;</p><p> dezenaUmid = umid / 10;</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~8); //Set DISPLAY 1</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaUmid]); //Set the Humidity (ten)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~4); //Set DISPLAY 2</p><p> shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeUmid]); //Set the Humidity (unit)</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~2); //Set DISPLAY 3</p><p> shiftOut(dataPin, clockPin, LSBFIRST, B01100011); //Set the upper symbol of percentage [%] of Humidity</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set DISPLAY 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, B00011101); //Set the lower symbol of percentage [%] of Humidity</p><p> digitalWrite(latchPin, HIGH);</p><p> digitalWrite(latchPin, LOW);</p><p> shiftOut(dataPin, clockPin, LSBFIRST, ~1); //Set Display 4</p><p> shiftOut(dataPin, clockPin, LSBFIRST, 255); //Reset the DISPLAY 4 (to avoid some flicking)</p><p> digitalWrite(latchPin, HIGH);</p><p> }</p><p> delay(500); //Wait for half second before to restart</p><p>}</p>
<p>Great progress!!! I am really happy with that!!</p><p>Please, update the following statement for all these instances in the program:</p><p>.........</p><p>shiftOut(dataPin, clockPin, LSBFIRST, <strong>~255</strong>); //Reset the DISPLAY 4 (to avoid some flicking)</p><p>.........</p><p>In fact, ~255 means 0 (zero). You can replace by this if you prefer!</p><p>I think it will work this time ! :)</p>
<p>Don't worry!</p><p>You are almost there! :-)</p><p>You need use a <strong>Common Anode</strong> LED display.</p><p>Please, confirm this information and check again the wiring connections.</p>
<p>Veigrillen,</p><p>Just another remind. </p><p>Take a look at your module specification if the Vcc is 5V or 3.3V to avoid any problem when you connect it on Arduino.</p>
<p>where can I found dht11 library</p>
<p>Download of <strong>dht11 </strong>library:</p><p><a href="https://github.com/adalton/arduino/blob/master/projects/Dht11_Library/Dht11.cpp">https://github.com/adalton/arduino/blob/master/pro...</a></p>
<p>If i use 2 separate 4 digit 7 segment displays how can i change change the connections and program. Please guide me.</p>
<p>Akilal,</p><p>You must use two additional 74HC595 (shift registers IC) in cascade and also the corresponding resistors. </p><p>Each shift register output #9 must be connected to the serial data input #14 of next IC.</p><p>The program must be updated to manage the data in the right sequence to control the segments of displays.</p><p>Remember that you are transferring serial data to paralell output.</p><p>An easier way is to use a display of 8 digits x 7 segments as I did in my stopwatch project:</p><p><a href="https://www.instructables.com/id/Stopwatch-Lap-Time-With-Arduino-Nano-and-Maxi-7219/">https://www.instructables.com/id/Stopwatch-Lap-Time...</a></p>
thank you very much for your reply. In my case im using 02 numbers of 4 digit 7 segment displays. My requirement is to display separately time &amp; date together and Temp&amp; hum. together. So that i will try as you said before. Is there any change required for program i mean sketch?
<p>First attempt, and thumb up for me :-). Thank you sir for this project. 7 segment display is LG5643DH.</p>
<p>Great job!! Congrats and thank you !!</p>
<p>Greetings, and thank you so much for your work on this project. What I am trying to do, is something very simular, however I have obtained a small LED 7 seg display with a 4 pin input made by Catalex. the pins are clk - DIO - VCC and GND. I currently have it running it's demo clock program, but what I wish to do is to hook it up through a real time clock module on my Arduino Uno, to go in a project box that will hold my clock and electronic compass for our Motorhome while we explore our nation. It will also hold an altimeter so I can keep track of the altitude and Barometer. Any thoughts on how I could use this little device with your project?</p>
<p>sorry sir, can you help me to write the program in english , </p>
<p>Hello Fitri Pujir,</p><p>Today I have translated to English the comments of Digital_Clock program and I have added too some statements to show the Temperature in Fahrenheit degrees (&ordm;F) as an optional feature.</p><p>Thank you for your request. We always can improve something !</p><p>I hope you enjoy it !</p><p>Best regards,</p><p>LAGSILVA</p>
<p>Are you talking about the comments in the program ?</p>
<p>i tried to assemble your project multiple times with the YSD-439AB4B-35 7segment but it simply does not work....</p>
<p>Hello Vags,</p><p>According with the Datasheet of YSD-439AB4B-35 the pin numbers are completely different of the display I have applied in my project.</p><p>Please, check the differences and set the correponding pin numbers according with my display.</p><p>For example: Pin 11 = Pin 14 (in your display) / Pin 12 = Pin 1 ....</p><p>Please try this solution and tell me the results.</p>
<p>Hi<a href="https://www.instructables.com/member/lagsilva" rel="nofollow">lagsilva</a><br> </p><p>thank you for your time.</p><p> Yes i have tried the pins from the datasheet many times but still nothing... </p>
<p>Hi :D<br>Ive been working on a similar display. Im using the sparkfun display (only mine is red, not blue), and Im using 2 shift registers similar to the way this is set up. <br>Mine uses the first 4 (q0-q3) pins of the second shift register for the digit pins instead of the last 4 (q4-q7) though.<br>Mine is not working yet with the Digital_Clock_V1 program, but I do have it working with another program that uses the shift registers using LSB, and this is my number map.</p><p>// My segment bits, turn low (0) to light a segment<br>// ABCDEFGDP<br> B00000011, // 0<br> B10011111, // 1<br> B00100101, // 2<br> B00001101, // 3<br> B10011001, // 4<br> B01001001, // 5<br> B01000001, // 6<br> B00011111, // 7<br> B00000001, // 8<br> B00011001, // 9<br><br>Im trying to modify this code to work with my setup, its not exactly the same as his though, and the program isnt working right yet with my number map.</p>

About This Instructable

30,168views

56favorites

License:

Bio: I am a Mechanical Engineer and an enthusiastic Maker. I like to develop new ideas combining electronics and programming.
More by lagsilva:Chinese Rings Puzzle With Arduino Talking Clock with Arduino Stopwatch with Lap Time Counter 
Add instructable to: