[SOLVED]Broken Code ?

Ok so I have been playing with 3 max7219 and 3 8x8 grids. I hooked it up a couple times but I was getting strange results, which seemed random. I decided to rewire, and try again, setting up each 8x8 grid individually. As a single max7219 and an 8x8 grid, each of the work proper, where the coded LED's light up. As soon as I connect my digital out from one max7219 to digital in of the next max7219, only the first one lights up. I figured I would test some code, so I found some nice work from Crossroads (thanks for the use), and it works fine.

/* 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 (0x0f);
  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(200);

  Serial.println("Display test on");

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

  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);
    SPI.transfer(displayArray[x-1]);// array 0 to 7
    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

This seems to be doing what it should, at first all the LED grids all light up then the flashing starts.
So I changed my arduino pins to match Crossroads code, just to make my life easy, and ran my code, I still get the same thing, which is only one 8x8 grid lighting up. I am pretty sure the parts/pieces are connected properly, otherwise Crossroads code shouldn't work, right?
So here is my code, I am definitely not doing something to make the second and third max7219 and their corresponding 8x8 grids fire properly.

#include "binary.h"  //Use this include for writing a byte in binary
#include "LedControl.h"//Use this include for controling LED's
LedControl lc=LedControl(11,13,10,3); /// Arduino data pin,clock pin,device selecting pin, number of max7219's


void setup()
{
 
  lc.shutdown(0,false); // Turn off shutdown
  lc.setIntensity(0,1); // Set the intensity ... first device to 5
  lc.setIntensity(1,1); // Set the brightness ... second device 5
  lc.setIntensity(2,1); // Set the brightness ... third device to 5
}

void loop()
{
 
  lc.setRow(0,0,B10010101); // First row of LED's...first max7219
  lc.setRow(1,0,B00101100); // First row of LED's...second max7219
  lc.setRow(2,0,B10101001); // First row of LED's...third max7219

  lc.setRow(0,1,B10010100); // Second row of LED's...first max7219
  lc.setRow(1,1,B10101100); // Second row of LED's...second max7219
  lc.setRow(2,1,B10100101); // Second row of LED's...third max7219

  lc.setRow(0,2,B10101001); // Third row of LED's...first max7219
  lc.setRow(1,2,B01001101); // Third row of LED's...second max7219
  lc.setRow(2,2,B01001010); // Third row of LED's...third max7219

  lc.setRow(0,3,B10100101); // Fourth row of LED's...first max7219
  lc.setRow(1,3,B01001101); // Fourth row of LED's...second max7219
  lc.setRow(2,3,B01001010); // Fourth row of LED's...third max7219

  lc.setRow(0,4,B10100101); // Fifth row of LED's...first max7219
  lc.setRow(1,4,B00101101); // Fifth row of LED's...second max7219
  lc.setRow(2,4,B00101001); // Fifth row of LED's...third max7219

  lc.setRow(0,5,B10010101); // Sixth row of LED's...first max7219
  lc.setRow(1,5,B00101100); // Sixth row of LED's...second max7219
  lc.setRow(2,5,B10101001); // Sixth row of LED's...third max7219
  
}

Anyone have any Ideas ? Does anyone want to test the code on their equipment? Who knows maybe I haven't connected things up right. I am not sure currently as I am at a loss for ideas.
Thanks in advance for any advice. Well I am going to watch Crossroads code flash up my LED grids ;).

EDIT: I just wanted to say this is all set up on a bread board… maybe that is part of the problem, but once again Crossroads code works well.

hmn another thing too, I do not recall downloading SPI.h , I guess that library is already included then?
I got home last night and took a look at my grids watching them flash with Crossroads code, i noticed row 7 and 8 on grid two are paired up, instead of staggered. Also row 6and 7 are likewise paired instead of staggered.

First write some code to light LED in turn, slowly, and check that's working before
trying to debug multiple LEDs lit at once. Should make it much easier to see where
the problem is (if its slow you can stick multimeter probes on as it switches).

Ok so I found this online, as I needed something to test that would be working already.
http://www.pjrc.com/teensy/td_libs_Matrix.html
I uploaded the libraries, and ran this code

#include <Sprite.h>  // Sprite before Matrix
#include <Matrix.h>

const int numChips = 3;

//                   DIN, CLK, LOAD, #chips
Matrix myLeds = Matrix(11, 13, 10, numChips);

void setup() {
  myLeds.clear();
}

void loop() {
  byte x, y;

  // light one LED at a time, scanning left to right
  // and top to bottom... useful for testing the matrix
  for (y=0; y<8; y++) {
    for (x=0; x<(numChips * 8); x++) {
      myLeds.write(x, y, HIGH);
      delay(500);
      myLeds.write(x, y, LOW);
    }
  }
}

so this is suppose to run from left to right, it however runs right to left.
The other thing it is doing is as each LED lights up column one, (the on on left from my perspective)first then goes to 8,7,6,5,4,3,2 and then it hits the middle grid column 1 then once again 8,7,6,5,4,3,2, and so on until it repeats itself.
EDIT: oh yeah it also goes from bottom to top…. I thought maybe grid was upside down so I flipped it end for end, and yeah it lit up like I had cathode and anode all backwards. Thanks Mark, I was actually looking for some when you made your reply, good solid advice, as now I can see what it is , and isn't doing. I still don't get it though.

Alright another breakthrough, perspective…
So I uploaded this code

#include <Sprite.h>  // Sprite before Matrix
#include <Matrix.h>

//                  DIN, CLK, LOAD, #chips
Matrix myLeds = Matrix(11, 13, 10, 3);

Sprite letter_L = Sprite(5, 8,
  B11000,
  B11000,
  B11000,
  B11000,
  B11000,
  B11000,
  B11111,
  B11111
);
Sprite letter_E = Sprite(5, 8,
  B11111,
  B11111,
  B11000,
  B11110,
  B11110,
  B11000,
  B11111,
  B11111
);
Sprite letter_D = Sprite(6, 8,
  B111100,
  B111110,
  B110111,
  B110011,
  B110011,
  B110111,
  B111110,
  B111100
);
Sprite letter_S = Sprite(5, 8,
  B01110,
  B11111,
  B11000,
  B11110,
  B01111,
  B00011,
  B11111,
  B01110
);

void setup() {
  myLeds.clear();
  myLeds.setBrightness(4);
  myLeds.write(0, 0, letter_L);
  myLeds.write(6, 0, letter_E);
  myLeds.write(12, 0, letter_D);
  myLeds.write(19, 0, letter_S);
}

void loop() {
}

I found it here as well
http://www.pjrc.com/teensy/td_libs_Matrix.html
Well looking at grids my breadboard seems to be upside down. I flip my bread board, and I can almost red LEDS… give or take a column of less on the last grid, that should be on the first grid. My "L" only has on column my "E" has 3 columns of solid… and my "S" has an extra column on the last one, which appears as if it should be on the "L".

Well I got it fixed, though I really have no idea what happened or how I fixed it.
I set up my max7219's and 8x8 grids, on a piece of code from online and it worked, then I rebuilt my code line by line in a new sketch, tested each line and the LED's all light up, I only copied and pasted from my old sketch, so I really have no clue what went wrong, or why it even got fix, though happy to say it works. I attached a potentiometer to variable the light intensity too. works good.

Ok I got it figured out… LOL funny funny. I simply did not include a rather important piece of code, which prevented the other LED matrix's from running

lc.shutdown(0,false);

that was all I had, and I need one for each…. so adding

lc.shutdown(0,false);
lc.shutdown(1,false);
lc.shutdown(2,false);

makes it all work.
Thanks guys , as for any other newbies out there… keep this in mind when dealing with max7219 and 8x8 grids. LOL

Hello Arduino Forum and Sensai,

Working on project using the Maxim7219.
Researching Arduino sketches and how they work.
There is a lot of work done based on the LedControl.h
library. Have traced this back to the Arduino playground at
http://playground.arduino.cc/Main/MAX72XXHardware

There is also some reference 'the Crossroads code'.
It looks like it uses an SPI.h library.

Does anybody know what is the source of the
'the Crossroads code'?

Thanks.

Allen in Dallas