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.