for anyone who cares:
working code for the arduino and the max7313.
you would have to lookup how to solder the adress pins on the max 7313. there are 64 combinations possible, so check out the datasheet. with combinations of more 7313 chips you can control 64 * 16 = 1024 LED (and dim them!) with 2 arduino pins!! A little hard to solder though.
this code interfaces two chips. First it flips through all the leds one by one, for 5 times. Then it dimms all the leds gradually all at once.
#include <Wire.h>
// code for max7313
// eric toering
// Using the Wire library (created by Nicholas Zambetti)
// On the Arduino board, Analog In 4 is SDA, Analog In 5 is SCL
void stuur(byte adres, byte reg, byte data);
byte plaat = 0x10; // adresses of max chips
byte plaat2 = 39;
int intensiteit = 0xff; //
byte chipdata = 0;
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
stuur(plaat, 0xf, 0x10); // blink 0 aan, 0x10 is glob uit
stuur(plaat, 0x6, 0x00); // input en output config.
stuur(plaat, 0x7, 0x00); // oninterresante getallen, afblijven!!
stuur(plaat, 0x2, 0xff); // global intensity reg.
stuur(plaat, 0x3, 0xff);
stuur(plaat, 0xe, 0xff); // config bit
stuur(plaat2, 0xf, 0x10); // blink 0 aan, 0x10 is glob uit
stuur(plaat2, 0x6, 0x00); // input en output config.
stuur(plaat2, 0x7, 0x00); // oninterresante getallen, afblijven!!
stuur(plaat2, 0x2, 0xff); // global intensity reg.
stuur(plaat2, 0x3, 0xff);
stuur(plaat2, 0xe, 0xff); // config bit
for (int i = 0x10; i < 0x17; i++){
stuur(plaat, i, 0x00);
stuur(plaat2, i, 0x00);
}
Serial.println("check");
delay(500);
for (int i = 0x10; i < 0x17; i++){
stuur(plaat, i, 0xff);
stuur(plaat2, i, 0xff);
}
delay(500);
}
void loop()
{
/* small routine for finding out how the adress pins are connected
for (int i = 0; i < 255; i++){
plaat = i;
stuur(plaat, 0xf, 0x10);
stuur(plaat, 0x6, 0x00);
stuur(plaat, 0x7, 0x00);
stuur(plaat, 0x2, 0xff);
stuur(plaat, 0x3, 0xff);
stuur(plaat, 0xe, 0xff);
stuur(plaat, 0x10, 0x00);
stuur(plaat, 0x11, 0x00);
stuur(plaat, 0x12, 0x00);
stuur(plaat, 0x13, 0x00);
stuur(plaat, 0x14, 0x00);
stuur(plaat, 0x15, 0x00);
stuur(plaat, 0x16, 0x00);
stuur(plaat, 0x17, 0x00);
Serial.println(i, DEC);
delay (5);
}
for (int i = 0; i < 255; i++){
plaat = i;
stuur(plaat, 0xf, 0x10);
stuur(plaat, 0x6, 0x00);
stuur(plaat, 0x7, 0x00);
stuur(plaat, 0x2, 0xff);
stuur(plaat, 0x3, 0xff);
stuur(plaat, 0xe, 0xff);
stuur(plaat, 0x10, 0xff);
stuur(plaat, 0x11, 0xff);
stuur(plaat, 0x12, 0xff);
stuur(plaat, 0x13, 0xff);
stuur(plaat, 0x14, 0xff);
stuur(plaat, 0x15, 0xff);
stuur(plaat, 0x16, 0xff);
stuur(plaat, 0x17, 0xff);
Serial.println(i, DEC);
delay (5);
}
}
*/
for (int y = 0; y < 5; y++){
for (int i = 0; i < 16; i++){
if ((i % 2)>0){ stuur(plaat2, (0x10+(i / 2)), 0x0F);
}
else { stuur(plaat2, (0x10+(i / 2)), 0xF0);}
delay(60);
stuur(plaat2, (0x10+(i / 2)), 0xFF);
}
for (int p = 0; p < 16; p++){
int i = 15 - p;
if ((i % 2)>0){ stuur(plaat, (0x10+(i / 2)), 0x0F);
}
else { stuur(plaat, (0x10+(i / 2)), 0xF0);}
delay(60);
stuur(plaat, (0x10+(i / 2)), 0xFF);
}
}
for (int x = 0; x< 5; x++){
while (intensiteit > 0){
for (int i = 0x10; i < 0x18; i++){
stuur(plaat, i, intensiteit);
stuur(plaat2, i, intensiteit);
}
delay(40);
intensiteit -= 0x11;
}
while (intensiteit < 0xff){
for (int i = 0x10; i < 0x18; i++){
stuur(plaat, i, intensiteit);
stuur(plaat2, i, intensiteit);
}
delay(60);
intensiteit += 0x11;
}
}
for (int i = 16; i > 0; i--){
if ((i % 2)>0){ stuur(plaat2, (0x10+(i / 2)), 0x0F);
}
else { stuur(plaat2, (0x10+(i / 2)), 0xF0);}
delay(50);
stuur(plaat2, (0x10+(i / 2)), 0xFF);
}
for (int i = 0; i < 16; i++){
if ((i % 2)>0){ stuur(plaat, (0x10+(i / 2)), 0x0F);
}
else { stuur(plaat, (0x10+(i / 2)), 0xF0);}
delay(80);
stuur(plaat, (0x10+(i / 2)), 0xFF);
}
}
void stuur(byte adres, byte reg, byte data){ // small hint: stuur = dutch for send
Wire.beginTransmission(adres);
Wire.send( reg);
Wire.send( data);
Wire.endTransmission();
}
have fun with it...
