#include "LedControl.h"
LedControl lc = LedControl(12, 10, 11, 1);
unsigned long delai1 = 500;
unsigned long delai2 = 50;
void setup() {
lc.shutdown(0, false);
/* Régler la luminosité à une valeur moyenne */
lc.setIntensity(0, 8);
/* Effacer l'afficheur */
lc.clearDisplay(0);
}
/*
Cette fonction affiche le mot "Arduino" sur la matrice,
lettre par lettre.
(Il faut au moins une matrice 5x7 pour voir les caractères)
*/
void ecrireArduinoSurMatrice() {
/* Données binaires pour chaque lettre */
byte a[5] = {B01111110, B10001000, B10001000, B10001000, B01111110};
byte r[5] = {B00010000, B00100000, B00100000, B00010000, B00111110};
byte d[5] = {B11111110, B00010010, B00100010, B00100010, B00011100};
byte u[5] = {B00111110, B00000100, B00000010, B00000010, B00111100};
byte i[5] = {B00000000, B00000010, B10111110, B00100010, B00000000};
byte n[5] = {B00011110, B00100000, B00100000, B00010000, B00111110};
byte o[5] = {B00011100, B00100010, B00100010, B00100010, B00011100};
/* Affichage des lettres une par une avec un petit délai */
byte* lettres[] = {a, r, d, u, i, n, o};
for(int l = 0; l < 7; l++) {
for(int ligne = 0; ligne < 5; ligne++) {
lc.setRow(0, ligne, lettres[l][ligne]);
}
delay(delai1);
}
/* Effacer la matrice après affichage */
for(int ligne = 0; ligne < 5; ligne++) {
lc.setRow(0, ligne, 0);
}
delay(delai1);
}
/*
Cette fonction allume des LED en lignes.
Le motif se répète sur chaque ligne et clignote autant de fois que le numéro de ligne.
*/
void lignes() {
for(int ligne = 0; ligne < 8; ligne++) {
delay(delai2);
lc.setRow(0, ligne, B10100000);
delay(delai2);
lc.setRow(0, ligne, 0);
for(int i = 0; i < ligne; i++) {
delay(delai2);
lc.setRow(0, ligne, B10100000);
delay(delai2);
lc.setRow(0, ligne, 0);
}
}
}
/*
Cette fonction allume des LED en colonnes.
Le motif se répète sur chaque colonne et clignote autant de fois que le numéro de colonne.
*/
void colonnes() {
for(int col = 0; col < 8; col++) {
delay(delai2);
lc.setColumn(0, col, B00100000);
delay(delai2);
lc.setColumn(0, col, 0);
for(int i = 0; i < col; i++) {
delay(delai2);
lc.setColumn(0, col, B00100000);
delay(delai2);
lc.setColumn(0, col, 0);
}
}
}
/*
Cette fonction allume chaque LED de la matrice.
Chaque LED clignote en fonction de la colonne.
*/
void uneParUne() {
for(int ligne = 0; ligne < 8; ligne++) {
for(int col = 0; col < 8; col++) {
delay(delai2);
lc.setLed(0, ligne, col, true);
delay(delai2);
for(int i = 0; i < col; i++) {
lc.setLed(0, ligne, col, false);
delay(delai2);
lc.setLed(0, ligne, col, true);
delay(delai2);
}
}
}
}
void loop() {
ecrireArduinoSurMatrice();
lignes();
colonnes();
uneParUne();
}