Arduino Matrix Clock


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.

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

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





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 > RTClib > ds3231 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:




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 that I found online but had to make a few changes. This is due to some outdated syntax/functions that the current libraries no longer support. Credit to original code is given to Electronics projects

Clock Features:

The clock is automatically set to display time in 24HR format but can be adjusted to give time in 12HR format. 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 below for clarification)

12HR Format: To have the clock tell time in 12HR Format, you’ll have to comment the line 88:

hour =Clock.getHour(h12,PM); //24HR Format

And uncomment lines 92 to 99:

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

Sleep Mode:

This is something I’ve included that was not in the original code. This simply lowers the brightness or intensity of the led matrix during selected hours. This feature is intended to be used at night (such as when you are asleep) to reduce the amount of light emitted in a room. The led matrix is very bright – even when it’s not on its highest intensity, and thus can light up a dark room very well. This could be annoying for some especially waking up in the middle of the night only to be blinded by the light as you check the time.

To enable sleep mode, uncomment lines 174 to 181

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

Note: Using sleep mode while also using 12HR mode you’ll notice that it will run twice a day since 8am and 8pm are interpreted as the same. For example, if you set Sleep Mode between the hours of 10 and 7, then Sleep Mode would be on between 10pm and 7am AND 10am to 7pm. To resolve this, the clock must be able to differentiate between AM and PM. This can best be achieved by adding such features, but I haven’t yet gotten around to a solution. However, this issue does not occur when the clock is in 24HR format.


In the event that something is not working as it should, remember these tips:

  • RECHECK your wiring! Check for any loose wires or wrong connections.

  • Make sure you have downloaded the correct libraries. There are many variations of the same libraries but please use the ones that listed in this guide.

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 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.



    • PCB Contest

      PCB Contest
    • Epilog X Contest

      Epilog X Contest
    • Faux-Real Contest

      Faux-Real Contest

    2 Discussions

    Hey, I've just add a few more images on the project including the completed breadboard circuit and a video. Click on the Clock Gallery on the conclusion to view them.