D15 | D14 | D13 | D12 | D11 | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
X | X | X | X | Adresse | DATA |
Registre | Adresse | HEX | ||||
---|---|---|---|---|---|---|
D15 D12 | D11 | D10 | D9 | D8 | ||
No-Op | X | 0 | 0 | 0 | 0 | 0xX0 |
Digit 0 | X | 0 | 0 | 0 | 1 | 0xX1 |
Digit 1 | X | 0 | 0 | 1 | 0 | 0xX2 |
Digit 2 | X | 0 | 0 | 1 | 1 | 0xX3 |
Digit 3 | X | 0 | 1 | 0 | 0 | 0xX4 |
Digit 4 | X | 0 | 1 | 0 | 1 | 0xX5 |
Digit 5 | X | 0 | 1 | 1 | 0 | 0xX6 |
Digit 6 | X | 0 | 1 | 1 | 1 | 0xX7 |
Digit 7 | X | 0 | 0 | 0 | 0 | 0xX8 |
Decode mode | X | 1 | 0 | 0 | 1 | 0xX9 |
Intensité | X | 1 | 0 | 1 | 0 | 0xXA |
Scan Limit | X | 1 | 0 | 1 | 1 | 0xXB |
Schutdown | X | 1 | 1 | 0 | 0 | 0xXC |
Display Test | X | 1 | 1 | 1 | 1 | 0xXF |
Adr | Data | Désignation |
---|---|---|
0x09 | 0x00 | decoding :BCD off |
0x0a | 0x03 | brightness 0.3.F |
0x0b | 0x07 | scanlimit → 8 LEDs |
0x0c | 0x01 | power-down mode:0,normal mode:1 |
0x0f | 0x00 | test display:1;EOT,display:0 |
|
|
L'ordre des informations est le suivant : 0x10,0x78,0x38,0x78,0x28,0x44,0x44,0x44, 0x44,0x44,0x40,0x44,0x44,0x78,0x40,0x44, 0x7C,0x44,0x40,0x44,0x44,0x44,0x44,0x44, 0x44,0x78,0x38,0x78,0x00,0x00,0x00,0x00 En résumé, le balayage se fait d'un block à l'autre. A chaque ligne envoyer CS=LOW (Selectionner) envoyer adresse,data (x4) puis envoyer CS=HIGH. CS=LOW, Block 0 (0x01,DATA) → Block 1 (0x01,DATA) → Block 2 (0x01,DATA) → Block 3 (0x01,DATA) → CS=HIGH CS=LOW,Block 0 (0x02,DATA) → Block 1 (0x02,DATA) → Block 2 (0x02,DATA) → Block 3 (0x02,DATA) → CS=HIGH CS=LOW,Block 0 (0x03,DATA) → Block 1 (0x03,DATA) → Block 2 (0x03,DATA) → Block 3 (0x03,DATA) → CS=HIGH CS=LOW,Block 0 (0x08,DATA) → Block 1 (0x08,DATA) → Block 2 (0x08,DATA) → Block 3 (0x08,DATA) → CS=HIGH |
unsigned char i; #define Max7219_pinCLK 10 #define Max7219_pinCS 11 #define Max7219_pinDIN 12 void setup() { pinMode(Max7219_pinCLK,OUTPUT); pinMode(Max7219_pinCS,OUTPUT); pinMode(Max7219_pinDIN,OUTPUT); delay(50); //Initialiser Init_MAX7219(); } void loop() { Write_Max7219(1,0x10); Write_Max7219(2,0x30); Write_Max7219(3,0x50); Write_Max7219(4,0x10); Write_Max7219(5,0x10); Write_Max7219(6,0x10); Write_Max7219(7,B10101010); Write_Max7219(8,B01010101); delay(500); Write_Max7219(8,B10101010); Write_Max7219(7,B01010101); delay(500); } void Init_MAX7219(void) { Write_Max7219(0x09, 0x00); //decoding ï¼BCD off Write_Max7219(0x0a, 0x03); //brightness 3 Write_Max7219(0x0b, 0x07); //scanlimit 8 LEDs Write_Max7219(0x0c, 0x01); //power-down modeï¼0; normal modeï¼1 Write_Max7219(0x0f, 0x00); //test displayï¼1ï¼ EOT displayï¼0 } //Ecriture sur une rangee void Write_Max7219(unsigned char address,unsigned char dat) { digitalWrite(Max7219_pinCS,LOW); Write_Max7219_byte(address); //addresse LED Write_Max7219_byte(dat); //data LED digitalWrite(Max7219_pinCS,HIGH); } // Ecriture sur un 8x8 void Write_Max7219_byte(unsigned char DATA) { unsigned char i; digitalWrite(Max7219_pinCS,LOW); for(i=8;i>=1;i--) { digitalWrite(Max7219_pinCLK,LOW); digitalWrite(Max7219_pinDIN,DATA&0x80);// Extracting a bit data DATA = DATA<<1; digitalWrite(Max7219_pinCLK,HIGH); } }