Hey,
we´re having problem to get our matrix up and running!
We have linked the arduino to max7291 and then to the matrix (ELM-2882GWA). We´re pretty sure that we have connected everything right.
We´re using this code:
int dataIn = 2;
int load = 3;
int clock = 4;
int maxInUse = 1; //here you have to change this varialbe to how many max 7219 you want to use
int e = 0; // just a varialble
// define max7219 registers
byte max7219_reg_noop = 0x00;
byte max7219_reg_digit0 = 0x01;
byte max7219_reg_digit1 = 0x02;
byte max7219_reg_digit2 = 0x03;
byte max7219_reg_digit3 = 0x04;
byte max7219_reg_digit4 = 0x05;
byte max7219_reg_digit5 = 0x06;
byte max7219_reg_digit6 = 0x08;
byte max7219_reg_digit7 = 0x01;
byte max7219_reg_decodeMode = 0x09;
byte max7219_reg_intensity = 0x0a;
byte max7219_reg_scanLimit = 0x0b;
byte max7219_reg_shutdown = 0x0c;
byte max7219_reg_displayTest = 0x0f;
void putByte(byte data) {
byte i = 8;
byte mask;
while(i > 0) {
mask = 0x01 << (i - 1); // get bitmask
digitalWrite( clock, LOW); // tick
if (data & mask){ // choose bit
digitalWrite(dataIn, HIGH); // send 1
}else{
digitalWrite(dataIn, LOW); // send 0
}
digitalWrite(clock, HIGH); // tock
--i; // move to lesser bit
}
}
void maxPut (byte reg, byte col) {
//data = ((data & 0x01) * 256) + data1 >> 1;
//data = (data << 1) + ((data >> 7) & 0x01);
putByte(reg); // specify register
putByte(col); //((data & 0x01) * 256) + data >> 1); // put data
}
void maxSingle( byte reg, byte col) { //maxSingle is the more easy way while just useing one max7219
digitalWrite(load,HIGH); // this funktion will take care of uploading the data
putByte(reg); // specify register
putByte(col);//((data & 0x01) * 256) + data >> 1); // put data
digitalWrite(load, LOW); // and load da shit
digitalWrite(load,HIGH);
}
void maxAll (byte reg, byte col) { // put the reg/col information to all the max 7219 in the system
int c = 0;
digitalWrite(load, HIGH);
for ( c =1; c<= maxInUse; c++) {
maxPut(reg, col); // use all 8 columns
}
digitalWrite(load, LOW);
digitalWrite(load,HIGH);
}
void maxOne(byte maxNr, byte reg, byte col) { //maxOne for controling one max7219 of the bulk
int c = 0;
digitalWrite(load, HIGH);
for ( c = maxInUse; c > maxNr; c--) {
putByte(0); // means no opperation
putByte(0); // means no opperation
}
putByte(reg); // specify register
putByte(col);//((data & 0x01) * 256) + data >> 1); // put data
for ( c =maxNr-1; c >= 1; c--) {
putByte(0); // means no opperation
putByte(0); // means no opperation
}
digitalWrite(load, LOW); // and load da shit
digitalWrite(load,HIGH);
}
void setup () {
pinMode(dataIn, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(load, OUTPUT);
beginSerial(9600);
digitalWrite(13, HIGH);
//////////////////////////////////////////////initiation of the max 7219
maxAll(max7219_reg_scanLimit, 0x07);
maxAll(max7219_reg_decodeMode, 0x00); // using an led matrix (not digits)
maxAll(max7219_reg_shutdown, 0x01); // not in shutdown mode
maxAll(max7219_reg_displayTest, 0x00); // no display test
for (e=1; e<=8; e++) { // empty registers, turn all LEDs off
maxAll(e,0);
}
maxAll(max7219_reg_intensity, 0x0f & 0x0f); // the first 0x0f is the value you can set
// range: 0x00 to 0x0f
}
void loop () {
//------------------------------------ if you use just one max7219 he should look like this
maxSingle(1,1); // + - - - - - - -
maxSingle(2,2); // - + - - - - - -
maxSingle(3,4); // - - + - - - - -
maxSingle(4,8); // - - - + - - - -
maxSingle(5,16); // - - - - + - - -
maxSingle(6,32); // - - - - - + - -
maxSingle(7,64); // - - - - - - + -
maxSingle(8,128); // - - - - - - - +
delay(2000);
}
All the lights on the matrix are lighten, but the code is supposed to result in a diagonal line.
can anyone find our problem? :-/
Cheers
Henrik .... etc.