Analog Vs Digital Clock(using MAX7219 LED Dot Matrix Display)

Today in this video we will discuss how to make a Digital Clock using MAX7219 LED Display. This LED Display consists of Four 8*8 LED Matrix Display.

four led matrix

At first the HexaDecimal files comes to the Microcontroller then it comes to the Peripheral Part means to the LED Display.

Hexfiles

Here I used D1 Mini as Microcontroller, anyone can used ESP8266 instead of D1 Mini.

Please support us on YouTube also. Like Share and Subscribe to our channel : https://youtube.com/c/RatnasRoboLab

Components

(1) MAX7219 Dot Matrix MCU LED Display Control Module Kit : https://amzn.to/3V5eboN
(2) Wemos® D1 Mini NodeMcu Lua WIFI ESP8266 Development Board: https://amzn.to/41IWgXw
(3) Programming USB Cable: https://amzn.to/3Nj01yj
(4) MAX7219 Display 4 in 1 : https://amzn.to/3n3DI4Y

Circuit Diagram

circuit diagram max7219
Controller D1 Mini and MAX7219 LED Display

Step By Step

Ok let it be simple, first glow the first LED in the first row in the first 8*8 LED Matrix.

1 led 1 row

In this way we can easily create the digit 0 by sending HexaDecimal files to the Microcontroller.

digit0

Similarly we create the array of HexaDecimals for the each digit and sending these array of HexaDecimal files to the 1st 8*8 LED Matrix.

array of hex

Finally we send these array of HexaDecimals to 2nd, 3rd and 4th 8*8 LED Matrix.

We can now easily make a Digital Clock by setting the Time that after every minute 1st and 2nd 8*8 LED Matrix changes and every 60 minute Hour segment means 3rd an 4th 8*8 LED Matrix changes.

clock

Code

#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN   14   // or SCK  D5
#define DATA_PIN  13  // or MOSI D7
#define CS_PIN    2  // or SS   D4

MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);   // SPI hardware interface

unsigned char setzero[8]={0x38, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x38}; //Digit 0
unsigned char setone[8]={0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e};  //Digit 1
unsigned char settwo[8]={0x38, 0x6c, 0x0c, 0x0c, 0x38, 0x60, 0x6c, 0x7c};  //Digit 2
unsigned char setthree[8]={0x38, 0x6c, 0x0c, 0x3c, 0x0c, 0x0c, 0x6c, 0x38};//Digit 3
unsigned char setfour[8]={0x0c, 0x1c, 0x2c, 0x6c, 0x7c, 0x0c, 0x0c, 0x0c}; //Digit 4

unsigned char setfive[8]={0x7c, 0x60, 0x60, 0x78, 0x0c, 0x0c, 0x6c, 0x78}; //Digit 5
unsigned char setsix[8]={0x38, 0x6c, 0x60, 0x78, 0x6c, 0x6c, 0x6c, 0x38};  //Digit 6
unsigned char setseven[8]={0x7c, 0x7c, 0x0c, 0x18, 0x30, 0x60, 0x60, 0x60};//Digit 7
unsigned char seteight[8]={0x38, 0x6c, 0x6c, 0x38, 0x6c, 0x6c, 0x6c, 0x38};//Digit 8
unsigned char setnine[8]={0x38, 0x6c, 0x6c, 0x3c, 0x0c, 0x0c, 0x4c, 0x38}; //Digit 9

void setup() 
{
  // put your setup code here, to run once:
     mx.begin();
}

void loop() 
{
         for (int j=0; j<8; j++)
         {
          mx.setRow(i, j, setzero[j]);   // For setting Digit Zero 
         }
}

Code to Note

mx.setRow(i, j, 0x00) – In this function the parameter i is used for which LED Matrix we want to display. If we set i=0; then 1st LED Matrix will glow, if we set i=3; then 4th LED Matrix will glow. The parameter j is used for which row we want to display. If we set j=0; then in 1st row will glow, if we set j=7; then in 8th row will glow.

Result

By this program we can control any LED that we want to glow in the big 32*8 LED Display by sending array of Hexa Decimals. Similarly, we can also reprogram the ARDUINO and change the Hexa Decimals and make any kind of animations.

Further Readings

  • Arduino Tutorial 5 : Serial Control 8 LED’s
  • 3x3x3 Led Cube

If you liked this article, then please subscribe to our YouTube Channel. You can also find us on InstagramFacebook and Twitter.

READ – CONNECT – BOOST – CREATE