Arduino Matrix Clock

1,552

2

22

Description:

Build your clock using an Arduino, a matrix display, and a Real Time Clock (RTC) module. This is a fun and simple project which I feel is great for beginners. The clock uses the RTC module to accurately track time as well as the day, month, and year. In addition, the module has a built-in temperature sensor. You can learn more about the DS3231 module here as well as the I2C communication bus used for it here. Lastly we will use a Dot Matrix Display to of course, display the time, day of the week, month .etc. You can more about the display here and the MAX7219 IC driver in the datasheet below.

You can also download the pdf version for this project here. It's virtually the same as this instructable.

[UPDATE: 2/22/19] Don't use the pdf guide, I've updated this instructable but those changes are not yet reflected on the pdf.

Step 1: Gather Components

The components you'll need for this project:

In addition, you’ll need an Arduino of any kind (preferably a Nano to minimize the size of the project), a breadboard, jumper wires as well as the Arduino IDE installed on your PC.

Step 2: Libraries

<br>

Download the following libraries and install the .zip file to the Arduino IDE by going
to Sketch > Include Library > Add .Zip library

NOTE: THE VERSIONS MATTER!!!

* Verify that you have the correct versions before downloading. I'd recommend downloading each library within the Arduino IDE to be on the safe side.

MD_Parola 3.0.1: https://github.com/MajicDesigns/MD_Parola

MD_MAX72XX 3.0.2: https://github.com/MajicDesigns/MD_MAX72XX

DS3231 1.0.2: https://github.com/NorthernWidget/DS3231

Alternatively,

In the Arduino IDE go to Sketch > Include Library > Manage Libraries and in the search bar type: “MAX72XX” and you should see the following (See image):

Install only MD_MAX72XX and MD_Parola. MD_MAXPanel is NOT needed.

Step 3: Testing Your Components

After Installing the libraries, test your components individually to ensure that they are working as they should. Please follow these steps before wiring everything together.

To test DS3231 RTC Module, Connect the DS3231 to the Arduino (see Wiring below). Then in the Arduino IDE, go to Files > Examples > DS3231 > DS3231_Test and upload the sketch. Open the Serial Monitor and check to see that you’re getting the correct date, time, day .etc.

To test the matrix display, first connect it to the Arduino (see Wiring below). Next, in the Arduino IDE, go to Files > Examples > MD_Parola > Parola_HelloWorld and upload the sketch. You should see HELLO printed on the display and it may or may not be printed backwards. If the text is backwards then you must change the following line:

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW

To

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

Upload the sketch again and the problem should be resolved.

Now that we’ve tested our components, we are ready to wire everything together!

Step 4: Wiring

Refer to the diagram or schematic or table

Step 5: CODE


Get the code here

Note: I used a code originally by Electronic Projects but modified it to support current (at the time of completion) libraries.

Clock Features:

The clock is automatically set to tell time in 24hr format but it can be easily changed to 12hr. The clock will also display the temperature (both in Celsius and Fahrenheit). I've also included a feature called 'Sleep Mode' which is set to "OFF" (See Sleep Mode below for details).

12hr Format: To set the clock to tell time in 12hr format, you'll have to comment line 88

hour =Clock.gethour(h12,PM); //24hr Format 

And uncomment lines 93 through 100

if (Clock.getHour(h12,PM)>=13 || Clock.getHour(h12,PM)==0) 
{
   h = Clock.getHour(12,PM) - 12;
}
   else
{
   h = Clock.getHour(h12,PM);
}

Sleep Mode:

This is a feature that helps reduce the brightness of the clock particularly during the hours in which we are asleep. I don't think you want to wake up in the middle of the night and by blinded by this clock. It is very bright even when it's at the lowest setting. To enable sleep mode, uncomment lines 177 to 184

if(h == 12 || h<8) //Time intervals (in this case, from 12AM to 8AM)
{
   P.setIntensity(0); //Set display brightness to lowest setting
}
   else 
{
   P.setIntensity(6); //Set display brightness to 6 (15 is the brightest)
}

Note: I've come across an issue when using sleep mode while the clock is set to 12hr mode. You'll notice that it will run twice a day since 8am and 8pm are interpreted both as 8. So if you set Sleep Mode to be active from 9pm to 7am, then it will also be active from 9am to 7pm. HOWEVER, this issue does not occur if the clock is set to 24hr mode.

Step 6: Conclusion

Congrats!!! You have a working clock. This is how mine turned out [Clock Gallery]. I hope that you not only learned a little bit more about components and coding, but that you enjoyed the journey getting there. Please share with me your thoughts on this guide over at anthotroncis@gmail.com. This is in fact my first project guide and hoped it served you well. I hope to create many more guides. In addition, if you have any questions, suggestions, and/or improvements on the project, feel free to message me.

Share

    Recommendations

    • Arduino Contest 2019

      Arduino Contest 2019
    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure

    22 Discussions

    0
    None
    7Franco

    Question 2 days ago

    Un saludo.
    Muy interesante este proyecto, les agradezco de antemano por compartir sus conocimientos.
    Estoy intentando hacer el montaje pero al compilar el boceto se produce el error:
    Error al compilar la tarjeta Arduino / Genuino Uno.
    Estoy utilizando las bibliotecas que indicó en el paso 2 en las versiones sugeridas.
    Sería tan amable de explicar qué hacer para solucionarlo, si lo desea, puede responder al correo electrónico: jhonfranco@outlook.com.
    Estaré muy agradecido.

    0
    None
    AzzmiS

    Question 4 weeks ago

    First of all thank you for your tutorial, its really help me doing my first project as a college student. I have some trouble in my code, i had downloaded DS3231 1.0.2 libraries but i got a trouble as you can see in the image. The problem is "Error Compiling for board Arduino/Genuino Uno"

    And once more, would you like to upload your newest code? it will really helpful for us. thank you, author for your helpfulness.

    Capture4.PNG
    4 answers
    0
    None
    AnthoTRONICSAzzmiS

    Answer 4 weeks ago

    Hey, this has been brought to my attention a lot recently so I've found another DS3231 library that will hopefully resolve the issue. I've updated this instructable and if you click on the get code link in Step 5, you will be redirected to my GitHub page for this project. I've uploaded the most recent code. Now, there is nothing to change in the code itself but just remove the RTClib library and download this one (which is also mentioned in Step 2) : https://github.com/NorthernWidget/DS3231. Once that's done, it should be working (fingers-crossed). Let me know if it worked!

    0
    None
    AzzmiSAnthoTRONICS

    Reply 4 weeks ago

    thank you for your help and reply, author. I've done all the step you said. but the problem is still here. I've changed my arduino uno to nano same as you too, but it didn't fix the problem.

    WhatsApp Image 2019-03-24 at 14.37.21.jpegWhatsApp Image 2019-03-24 at 14.37.22.jpeg
    0
    None
    AnthoTRONICSAzzmiS

    Reply 26 days ago

    When you get that error, if you scroll up on that black area, it should say why the error is occurring. What is that message saying?

    0
    None
    AnthoTRONICSBarzanM1

    Answer 26 days ago

    You can download the file by clicking on the get code here link in step 5. There you can download the code as well as the Font_Data.h or just copy the code. Make sure that when you open the Matrix_Clock.o file that you see both files like so

    1.png
    0
    None
    vicnorris

    Question 6 weeks ago

    Hi I have just undertaken your Arduino Clock as my first project. I am having trouble with the code. I have downloded the libraries as instructed but the Font_Data.h is missing according to the error message. Could you advise what to do now. Many Thanks

    11 answers
    0
    None
    AnthoTRONICSvicnorris

    Answer 6 weeks ago

    Hey, did you download the code in the get code here link above? The Font_Data.h is there. You have to put this file inside the same folder as the Matrix_Clock.ino code file. If not, create a folder called Matrix_Clock (Note, it must be the same name as the .ino file but without the .ino). Now when you open the Matrix_Clock.ino, you should see Font_Data.h file in a new tab in the Arduino IDE. Now, compile. Please message me if you need further assistance :)

    1.png
    0
    None
    vicnorrisAnthoTRONICS

    Reply 5 weeks ago

    Hi It's me again. I have reinstalled the Parola library I was using version 3.0.2.that seems to have sovled the 'numeric7Seg' problem only to indicate an error in the next line - include<DS3231.h> Cannot find file. As I said earlier this is my first project, please forgive me for keep bothering you. Many Thanks.

    0
    None
    AnthoTRONICSvicnorris

    Reply 5 weeks ago

    No troubles, what is the exact error message that you are getting?

    0
    None
    vicnorrisAnthoTRONICS

    Reply 5 weeks ago

    The error message reads - DS3231.h: No such file or Directory.

    0
    None
    AnthoTRONICSvicnorris

    Reply 5 weeks ago

    I assume that you do have the library for the DS3231 installed so do you perhaps by any chance have include<DS3231.h> instead #include<DS3231.h> in your code?

    0
    None
    vicnorrisAnthoTRONICS

    Reply 5 weeks ago

    Hi I am still having problems. The library for the DS3231
    was missing so I have now installed it. I now get the error message ‘error
    compiling for board Arduino Nano’ . The library’s I have installed are:

    MD_Payola (3.0.1)


    MD_MAX32XX (3.0.2)


    RTClib (1.2.0)


    DS3231 (1.0.2)


    I am also missing the library for wire.h I can’t find where to download it, can you
    help?

    The code I have was copied from your published project
    and pasted into the Arduino IDE


    Once again I would like to thank you for your assistance.

    0
    None
    AnthoTRONICSvicnorris

    Reply 5 weeks ago

    The wire.h library should already be pre-installed when you download the Arduino IDE. If you able to verify the code by clicking on the check to the upper left without any errors, then you're all set. If not, maybe you need to download the latest version of the IDE. Other than that, it seems that you've fixed everything in your code and what we're dealing with now is a mechanical issue. You are most likely getting this error because you are either uploading to the wrong board or do not have the correct port selected. Take a look at mine for example. When I connect my Nano I have to select that board under tools (If you're using an UNO, then you select Arduino/Genuino UNO). I also have to select what port I am using, for me that is port 5. Once you do that, everything should be good to go.

    Screenshot (75).pngScreenshot (76).png
    0
    None
    vicnorrisAnthoTRONICS

    Reply 5 weeks ago

    Hi I am still having problems and have decided to leave
    this project until I learn a bit more. I have Reinstalled the IDE. I now see
    that it was upgraded to version 1.8.9 two days ago. I am getting the same error
    message. I have checked and the wire.h library is there. I have checked the
    board and I have the Nano selected and is connected to port 4.


    I am now at a loss.The Library’s I have installed are:


    MD_Payola (3.0.1)


    MD_MAX32XX (3.0.2)


    RTClib (1.2.0)


    DS3231 (1.0.2)


    Many thanks for your help. If I can I would like to
    contact you at a later date.

    0
    None
    AnthoTRONICSvicnorris

    Reply 4 weeks ago

    Sorry to hear that, it can be frustrating to run into errors again in again. Sometimes the best solution is to take a break and come back to it with a fresh mind. As you said, this is your first project, you have work out the kinks but you will eventually get it and it will be so satisfying. Try researching that error "error
    compiling for board Arduino Nano." Let me know how it goes, you can reach me over at anthotroncis@gmail.com. Good Luck!

    0
    None
    vicnorrisAnthoTRONICS

    Reply 5 weeks ago

    Thanks for you prompt reply, That helped me solve that problem. There is now an error message I am having a problem with. The error is in the line below Case 2: // Clock and reads P.setFont (0, numeric7Seg); Error message reads - 'numeric7Seg' was not decleared in this scope. An help would be appricated. Many thanks.

    0
    None
    AnthoTRONICSvicnorris

    Reply 5 weeks ago

    Hmm...It seems that it's an issue with the Font_Data.h file. That's strange because based on the steps above, there should be no issues because 'numeric7Seg' is defined in that file. There should be no changes done to that file. It might also be that the libraries have updated and are bringing up some issues. The versions I'm used are as follows.

    MD_Parola 3.0.1
    MD_MAX72XX 3.0.2
    RTClib 1.0.2

    Check to see if you have the same versions. If not delete the library and reinstall with the versions mentioned above. See if this helps.