i've gone through the simple basics with the LED matrix and got it to work with 2 x 74HC595 shift registers.
now i'm "stepping up to the next level" and using the MAX7219 chip.
the sample code from the tutorial doesn't work, which led me to think it was a wiring problem, but after checking the pins again, and even testing a few individualLEDs by connecting a 'row' pin with a 'col' pin, i'm not sure what else to check.
i've pared down the code to it's most simplest form but even that fails, could you please take a look and see if the code at least is valid ?
the result is all the LEDs light up (wow, super bright like i've not seen them before using the 74HC595s !!) except for the last column.
here's the code i'm testing with;
// Code for Project 21 - from "Beginning Arduino 2nd Edition" - by Michael McRoberts)
int DataPin = 2; // Pin 1 on MAX
int LoadPin = 3; // Pin 12 on MAX
int ClockPin = 4; // Pin 13 on MAX
byte buffer[8];
#define DECODE_MODE_REG 0x09
#define INTENSITY_REG 0x0A
#define SCAN_LIMIT_REG 0x0B
#define SHUTDOWN_REG 0x0C
void clearDisplay() {
for (byte x=0; x<8; x++) {
buffer[x] = B00000000;
}
for (byte row = 0; row < 8; row++) {
writeData(row+1, buffer[row]);
}
}
void initMAX7219() {
pinMode(DataPin, OUTPUT);
pinMode(LoadPin, OUTPUT);
pinMode(ClockPin, OUTPUT);
clearDisplay();
writeData(SCAN_LIMIT_REG, B00000111); // scan limit set to 0:7
writeData(DECODE_MODE_REG, B00000000); // decode mode off
writeData(SHUTDOWN_REG, B00000001); // Set shutdown register to normal operation
intensity(15); // Values 0 to 15 only (4 bit)
}
void intensity(int intensity) {
writeData(INTENSITY_REG, intensity); //B0001010 is the Intensity Register
}
// The msb is the row of the matrix and
// the lsb is the dot pattern for the relevant character.
void writeData(byte msb, byte lsb) {
digitalWrite(LoadPin, LOW); // set loadpin ready to receive data
// Note: if you're interfacing with a device that's clocked by rising edges, you'll need to make sure that the clock pin is low before the call to shiftOut(), e.g. with a call to digitalWrite(clockPin, LOW).
//digitalWrite(ClockPin, LOW);
shiftOut(DataPin, ClockPin, MSBFIRST, (msb));
//digitalWrite(ClockPin, LOW);
shiftOut(DataPin, ClockPin, MSBFIRST, (lsb));
digitalWrite(LoadPin, HIGH); // latch the data
}
void setup() {
initMAX7219();
Serial.begin(9600);
// put in here, NOT loop()
// clearDisplay();
}
void loop() {
clearDisplay();
// scroll(" BEGINNING ARDUINO ", 45);
// scroll(" HELLO WORLD!!! :) ", 45);
writeData(8,8);
}
i don't get just one LED on, i get 7 columns, and if i comment that out and just leave the clearDisplay()
it's still the same result - something is fundamentally wrong here... i can't see it though.