Puoi caricare il codice ? A giorni dovrebbero, spero che arrivino i miei così provo ...

Ammazza... ma ancora non ti sono arrivati?
Questo sketch fa accendere i led di due matrici 8x8 (due MAX7219 in cascata);
Comunque ti avviso: non pensare di fare scritte scorrevoli o giochetti strani perchè hai solo 1k a disposizione; il codice che ho scritto per l'accensione dei led è veramente ridotto all'osso.
Ecco il codice:
const int dataIn = 0;
const int load = 1;
const int clock = 2;
const int maxInUse = 2; //change this variable to set how many MAX7219's you'll use
// define max7219 registers
const byte max7219_reg_noop = 0x00;
const byte max7219_reg_digit0 = 0x01;
const byte max7219_reg_digit1 = 0x02;
const byte max7219_reg_digit2 = 0x03;
const byte max7219_reg_digit3 = 0x04;
const byte max7219_reg_digit4 = 0x05;
const byte max7219_reg_digit5 = 0x06;
const byte max7219_reg_digit6 = 0x07;
const byte max7219_reg_digit7 = 0x08;
const byte max7219_reg_decodeMode = 0x09;
const byte max7219_reg_intensity = 0x0a;
const byte max7219_reg_scanLimit = 0x0b;
const byte max7219_reg_shutdown = 0x0c;
const byte max7219_reg_displayTest = 0x0f;
const byte array[] = {0,1,3,7,15,31,63,127,255};
const int ritardo = 35;
const byte acceso = 255;
const byte spento = 0;
byte array_flag[] = {0,0,0,0,0,0,0,0,0}; //array x flag accose/spento
void setup ()
{
pinMode(dataIn, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(load, OUTPUT);
//////////////////////////////////////////////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 (int 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
// accende singolarmente tutti i led della matrice // range: 0x00 to 0x0f
for(int i=1;i<9;i++)
{
for(int n=1;n<9;n++)
{
//assegna il flag corrente (i) con tutti i valori di array[]
array_flag[ i ] = array[n];
//richiama la funzione
maxAll(1,array_flag[1]);
maxAll(2,array_flag[2]);
maxAll(3,array_flag[3]);
maxAll(4,array_flag[4]);
maxAll(5,array_flag[5]);
maxAll(6,array_flag[6]);
maxAll(7,array_flag[7]);
maxAll(8,array_flag[8]);
delay(ritardo);
}
//lascia acceso il flag per il prossimo ciclo
array_flag[ i ] = acceso;
}
}
void loop (){}
void putByte(byte data) {
byte z = 8;
byte mask;
while(z > 0) {
mask = 0x01 << (z - 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
--z; // move to lesser bit
}
}
void maxAll (byte reg, byte col) { // initialize all MAX7219's in the system
int c = 0;
digitalWrite(load, LOW); // begin
for ( c =1; c<= maxInUse; c++) {
putByte(reg); // specify register
putByte(col);//((data & 0x01) * 256) + data >> 1); // put data
}
digitalWrite(load, LOW);
digitalWrite(load,HIGH);
}
Binary sketch size: 716 bytes (of a 1024 byte maximum) Ci può stare no?
