which LED is which

Hi Guys,

I am a complete newbee to this.

I have a max7219 with 8*8 LED matrix and it seems to be working fine with some code I got off one of the forums and made slight modifications - all good so far.

The problem is I cannot figure out how to make the LEDs light up as I want.

The code specifies these values to be lit up.
byte displayArray = {
0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //16 bytes

This makes sense for demonstration purposes but I wish to change and write something else. How about an “A”… what do I need to change display array to?

Thank you…

P.S. the complete code is given below… I cannot find the original forum.
Here is the link to the data sheet.
https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf

/* program to put message on a MAX7219s.
Set up in No Decode mode.
*/
// ************************************ //
//a_presetup
#include <SPI.h>

// define pins usage
// D11-12-13 SPI interface

byte ss0 = 10;
byte x;
// define variables
// bytes to send to MAX7219s, with some initial data
byte displayArray[] = {
 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //16 bytes

// define 7219 register addresses for setup
byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0
byte intensity_level = 0x0A; // 0x08 = mid level. Range is 0x00 to 0x0F
byte scan_limit = 0x0B; // 0x07 for all columns
byte shutdown_normal = 0x0C; // 0x00 - shutdown, 0x01 = normal
byte display_test = 0x0F; // 0x00 = normal, 0x01 = display test mode all on full

// ************************************ //

// b_setup
void setup(){

 pinMode (ss0, OUTPUT);
 digitalWrite (ss0, HIGH);

 Serial.begin(115200);

 // turn on SPI port
 SPI.begin();

 /*  set up MAX7219 registers  */

 // decode to No decode mode
 digitalWrite (ss0, LOW);
 SPI.transfer (decode_mode);
 SPI.transfer (0x00);
 digitalWrite (ss0, HIGH);

 Serial.println("No decode mode");

 // intensity to mid level
 digitalWrite (ss0, LOW);
 SPI.transfer (intensity_level);
 SPI.transfer (0x01);
 digitalWrite (ss0, HIGH);

 Serial.println("Intensity");

 // scan limit to all 7 columns
 digitalWrite (ss0, LOW);
 SPI.transfer (scan_limit);
 SPI.transfer (0x07);
 digitalWrite (ss0, HIGH);

 Serial.println("Scan Limit");


 // dispay test On
 digitalWrite (ss0, LOW);
 SPI.transfer (display_test);
 SPI.transfer (0x01);
 digitalWrite (ss0, HIGH);
 delay(2000);

 //Serial.println("Display test on");

 // dispay test to normal
 digitalWrite (ss0, LOW);
 SPI.transfer (display_test);
 SPI.transfer (0x00);
 digitalWrite (ss0, HIGH);
 delay(2000);

 Serial.println("Display test off");

 // shutdown to Normal mode
 digitalWrite (ss0, LOW);
 SPI.transfer (shutdown_normal);
 SPI.transfer (0x01);
 digitalWrite (ss0, HIGH);

 Serial.println("Normal mode");

 delay(250);

 Serial.println("setup done");

}
// ************************************ //

// c_loop
void loop(){

 // ************************************ //
 Serial.println("slaveSelect0 low "); // put data in registers 1 to 9. 16  bit transfer - address/data
 for (x = 1; x<9; x=x+1){
   digitalWrite (ss0, LOW);
   SPI.transfer (x);
//   delay(2000);
//   Serial.println(x);
   SPI.transfer(displayArray[x-1]);// array 0 to 7
//SPI.transfer(x);
   digitalWrite (ss0, HIGH);
 }

 delay(1000);

 Serial.println("slaveSelect0 high");

 for (x = 1; x<9; x=x+1){  
   digitalWrite (ss0, LOW);
   SPI.transfer (x);
   SPI.transfer(displayArray[x+7]); // array 8 t0 15
   digitalWrite (ss0, HIGH); 
 }

 delay(1000);

} // end loop

Please read the forum guidelines in the sticky post, then modify and correct your post above. Not just the code tags, but the other things you should also have included.

byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0

In what way is 0x09 setting it up in a no decode mode like all the comments say you need?

Plus do as Paul says.

You can write displayArray also in binary:

byte displayArray[] = {
  0b00000000,
  0b11000000,
  0b10100000,
  0b10010000,
  0b11110000,
  0b10001000,
  0b10000100,
  0b00000000,

  0b11111111,
  0b10000001,
  0b10000001,
  0b11111111,
  0b10000001,
  0b10000001,
  0b10000001,
  0b10000001};

Grumpy_Mike:

byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0

In what way is 0x09 setting it up in a no decode mode like all the comments say you need?

Plus do as Paul says.

Hi Grumpy_Mike,

Thanks for the reply. I have tried to modify the post as read me post suggests. However, I am new and still learning the forum etiquette. Please excuse the inadequacies.

From what I have gathered from the data sheet and different forums 0x00 is for controlling a 7 digit LED display. However I am not 100% on this. I am taking that as a given for now as the matrix is working with that setting.

I want to able to display a message of my liking on the matrix. I cannot determine the values i need to store in byte display array.

Best,

A

ahmadkh:
From what I have gathered from the data sheet and different forums 0x00 is for controlling a 7 digit LED display. However I am not 100% on this. I am taking that as a given for now as the matrix is working with that setting.

We are talking about the "Decode Mode" register - one I have never bothered about before! As it is described, it appears to be a bit mask for enabling the Hex decode function on each of 7 digits.

For a matrix, 0x00 is the correct value, for an 8-digit 7-segment display, you would set it to 0xFF iff you wished to use the decoder.

ahmadkh:
I want to able to display a message of my liking on the matrix. I cannot determine the values i need to store in byte display array.

Well a single 8-by-8 matrix is not much on which to display a message, you need a couple of these modules:

And you use Marco's "Parola" library to display and animate messages - look it up in the library manager.

ahmadkh:
rom what I have gathered from the data sheet and different forums 0x00 is for controlling a 7 digit LED display. However I am not 100% on this.

No you are quite right, sorry. The control byte for no decoding is in fact 00, I got that bit wrong.

For the no decoding you need to see the data sheet table 6.
Table 6.png

You will see it is backwards, well I think so. What it means that if you put the value 0x01 into the chip’s register number 0x01 then segment “e” will be lit up. Now depending on how your matrix is wired up one LED will be lit either on the left or right of the top line of the matrix. What ever way round you have it then you make up your displayed character one row at a time, with the top row going into register 0x01, second 0x02 all the way down to register 0x8.

Each register has the bytes corresponding to the bit pattern you want. So if you want a line down the left, then fill each register with the number 0x80. If you want the letter A then you need to look at each line in turn and turn it into a number.
Letter A.png

So for example the letter A would be:-
0x1C, 0x22, 0x22, 0x22, 0x3E, 0x2C, 0x2C

Assuming the wiring has segment “g” on the left hand side of the row.

There are lots of images showing character sets on the web, this one was taken from 3d dot matrix font