Using a 8x8 LED matrix with MAX7219 and Picaxe 28x1

djmikeys

New Member
Hi, I'm trying to control an 8x8 led matrix using the max7219 (http://datasheets.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf) and a Picaxe 28x1. I am currently unable to make it control the matrix at all, right now half the leds are on and half are off and the picaxe seems to have zero effect on its behaviour. Here is my simple code I am using to try and turn all the leds off:

'CLK - out1
'DIN - out2
'CS - out3

main:

low 3
spiout 1,2,MSBFirst_L,(%00000000/8,%00000000/8)
high 3

goto main



Can anyone tell me if this code is ok or not?

Cheers,
Mike
 

womai

Senior Member
I suggest you have a good reading of the datasheet's section that describes the command format (pages 6 - 10). You obviously haven't done that yet, otherwise you would not expect to turn everything on or off with just a single SPI command. I could write the code for you but I think you learn more when you dig in yourself.

In a nutshell, you will have to send several commands (not just one) to set all digits. Each command writes data for a single digit.

All commands are 2 bytes (MSB first, then LSB). The lower 4 bits of the MSB tell the chip which command it is (e.g. "load data for digit 3"). The LSB contains the actual data.

Make sure that you device does not come up in shutdown mode. To be safe, issue a "shutdown off" (i.e. normal operation) command (MSB = 0x0c, LSB = 0x01) before you do anything else.

Then, to get started, use the "Display test" command (0x0f) to turn all segments on at the same time.

Wolfgang
 

nbw

Senior Member
Also, do a search for 7219 in the forums - a gentleman by the name of Martin posted some very useful snippets on the 7219 there, particularly including start-up and other command handling as Womai said. You can do lots of semi-fancy things like blanking, and fancy things like controlling brightness, decode/no-decode digits, etc.

I have a 7219 running 6 digits on my salinity monitor, it works very nicely.
 
Top