MAX7219 Dot Matrix Module - Clock

Category : Electronics



MAX7219 Dot Matrix Module - Clock

This is a little project I am working on. I got myself 4  LED Matrix display 8×8 dots (MAX7219). These little 8×8 red LED matrix modules are super cute. I had 4 of the modules, so I took the code  from internet, stripped it down and created a mini clock. As well as the LED modules I used an Arduino to run code and a DS1307 clock module to keep time.

 

I used the following parts in order to build a clock:

 

Parts List

 

 

The DS1307 module

 

The DS1307 module contains a DS1307 chip that keeps time, along with a battery that runs the chip if the main power is disconnected. That way even if you unplug the clock, when you plug it back in the time will still be correct. It only needs 4 wires to work. 5v and GND for power, then SDA and SCL which are used to send clock data via the i2c protocol to the Arduino.

 

Connecting the LED Matrix modules:

 

Once your 4 matrix modules are joined together in a line with the black jumper connectors as described earlier, look for the end one with the DIN (Data In) pin free. Connect the pins on that matrix as follows:

  • Matrix LOAD to Arduino digital pin 10
  • Matrix CLK to Arduino digital pin 11
  • Matrix DIN to Arduino digital pin 12
  • Matrix 5v to Arduino pin 5v
  • Matrix GND to Arduino pin GND

 

 

Connecting the DS1307 module:

  • SDA to Arduino analog pin 4
  • SCL to Arduino analog pin 5
  • 5v to Arduino pin 5v
  • GND to Arduino pin GND

 

Connecting the Buttons:

  • Button 1 goes between Arduino digital pin 2 and GND
  • Button 2 goes between Arduino digital pin 3 and GND

 

Then  download the Mini LED Clock code from this page on GitHub by clicking the “Download Zip” button bottom right. Unzip the file and inside you will see 3 folders:

 

  • libraries – contains extra software code the clock needs to work
  • mini_clockx_x (where x is the version number) – this contains the main clock code.
  •  

Next job is to install the libraries. When you installed the Arduino software it should have created a folder somewhere for your sketches (projects) to go in. Inside that folder should be another folder called libraries. Open the libraries folder in the clock download and copy the 4 folders there into the libraries folder in your Arduino projects directory. The 4 libraries are called ‘Button’, ‘FontLEDClock’,  ‘LedControl’ and ‘RTClib’.

 

 

Troubleshooting

 

I get an error compiling:

  • Check the libraries are installed in the correct folder and appear in the menu
  • Make sure you have restarted the Arduino IDE after adding the libraries.
  • Make sure you  are using Arduino software version 1.6.5.

 

I get an error uploading to the Arduino:

  • Check your board type and serial settings are correct in the Tools menu.
  • Check your Arduino has 32K RAM or more.

 

The clock doesn’t change:

  • Normally a wiring issue. Check the LED on Pin 13 of the Arduino flashes. If not then the clock chip is not being read. Check your connections to the DS1307.
  • You must have a working battery on your DS1307 module for the clock to run.

 

The displays don’t light up / light up erratically.

  • Check your wiring to the first matrix.
  • Check all the jumper pins are pushed in on the other matrices.
  • Try another power supply.
  • Check each matrix with the Demo program as described earlier to make sure they are soldered correctly.

 

The text on the displays is rotated.

  • This is most likely because you don’t have the exact matrix modules from IC Station. Other modules from eBay can be wired up differently, so the LED’s are in a different order. You can usually fix things by tinkering with the function “plot” in the code. Look for the comment “plot a point on the display” and the line starting “void plot”. Switch the x and y in the 2 lines that start ” lc.setLed(address, y, x, true ); and  lc.setLed(address, y, x, false);”. This will plot the pixels 90 degrees around.

 

The text on the displays is garbled or out of order.

  • This is most likely because you don’t have the exact matrix modules from IC Station. Other modules from eBay can be wired up differently, so the LED’s are in a different order. You can usually fix things by tinkering with the function “plot” in the code. Look for the comment “plot a point on the display” and the line starting “void plot”. If the text is our of order you can try changing the address=0 to address=3 lines around. These control which display is 0,1,2, and 3. If you swap the numbers around so they go from 3 to 0 this will invert everything. It’s worked for a few people!