Friday 17 April 2015

8x8 Led Matrix using Max7219 IC


The Board

The Maxim 7219 IC

Info here

The Library (LedControl)

info here

The Code





Notes

Can be daisy chained..

setup functions

void setup()
{
  lc.shutdown(0,false);  // Wake up displays

  lc.setIntensity(0,1);  // Set intensity levels 1-15

  lc.clearDisplay(0);  // Clear Displays
}

lighting individual leds

/* 
 * Set the status of a single Led.
 * Params :
 * addr  address of the display 
 * row   the row of the Led (0..7)
 * col   the column of the Led (0..7)
 * state If true the led is switched on, 
 * if false it is switched off
 */
void setLed(int addr, int row, int col, boolean state);

example
//switch on the led in the 3'rd row 8'th column
//and remember that indices start at 0! 
lc.setLed(0,2,7,true);   
//Led at row 0 second from left too
lc.setLed(0,0,1,true);   
delay(500);
//switch the first Led off (second one stays on)
lc.setLed(0,2,7,false);



Control all leds in a row

The setRow(addr,row,value)-function takes 3 arguments. The first one is the already familiar address of our device. The second one is the row that is going to be updated and the third one the value for this row.

Here is the signature of the method :

/* 
 * Set all 8 Led's in a row to a new state
 * Params:
 * addr  address of the display
 * row   row which is to be set (0..7)
 * value each bit set to 1 will light up the corresponding Led.
 */
void setRow(int addr, int row, byte value);

example
//include this file so we can write down a byte in binary encoding
#include <binary.h>

//now setting the leds from the third row on the first device is easy
lc.setRow(0,2,B10110000);

Ref websites 

http://playground.arduino.cc/Main/LedControl
https://brainy-bits.com/tutorials/how-to-control-max7219-led-matrix/


No comments:

Post a Comment