Home LED projects 8×8 LED matrix example

8×8 LED matrix example

by shedboy71

This example switches on all the LEDs on a 8×8 LED matrix, the matrix is controlled by a MAX7219

 

LED matrix

LED matrix

Typically you will get these in kit format or they may be assembled, here is a picture of a typical module

8x8 matrix

8×8 matrix

VCC and GND pins are obvious

In the code below you can see the other required pin connections

Max7219_pinCLK = 10;
Max7219_pinCS = 9;
Max7219_pinDIN = 8;

Code

You will need to install  the Led Control library for this example

 

[codesyntax lang=”cpp”]

#include “LedControl.h”

/*
Max7219_pinCLK = 10;
Max7219_pinCS = 9;
Max7219_pinDIN = 8;
*/
LedControl lc=LedControl(8,10,9,1);

unsigned char i;
unsigned char j;
unsigned long delaytime=100;

void setup()
{
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}

void single() {
for(int row=0;row<8;row++)
{
for(int col=0;col<8;col++)
{
delay(delaytime);
lc.setLed(0,row,col,true);
delay(delaytime);
for(int i=0;i<col;i++)
{
lc.setLed(0,row,col,false);
delay(delaytime);
lc.setLed(0,row,col,true);
delay(delaytime);
}
}
}
}

void loop()
{
single();
lc.clearDisplay(0);
}

[/codesyntax]

 

Links
10PCS LED Dot Matrix Display Module Red 16Pin 8×8 Common Anode

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More