Bonjour,
J'ai une question à 5.. cents sur cet excellent tuto (Row-columm Scanning to control an 8x8 LED Matrix) !!?! que je tâche de comprendre à fond ...
=>
https://www.arduino.cc/en/Tutorial/RowColumnScanning
Note 1 : J'ai changé un chouga la config, je me passe de potentiomètre pour l'instant
analog pins 2 through 5 used as digital 16 through 19
=>
analog pins 0 through 3 used as digital 14 through 17
Note 2 : Je teste ces positions pixels[5][3] et pixels[1][7] = LOW;
=>
void setupScreen(){
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = HIGH;
}
}
//OFF current pos
//pixels[posX][posY] = LOW;
pixels[5][3] = LOW;
pixels[1][7] = LOW;
}
Voici mon code, je teste donc le "comment allumer une led de mon choix "
// 2-dimensional array of row pin numbers:
const int row[8] = {
2, 7, 17, 5, 13, 16, 12, 14
};
// 2-dimensional array of column pin numbers:
const int col[8] = {
6, 11, 10, 3, 15, 4, 8, 9
};
// 2-dimensional array of pixels:
int pixels[8][8];
int posX = 7;
int posY = 7;
int count = 1000;
int thisPixel;
int thisPixel2;
void setup() {
// initialize the I/O pins as outputs
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], HIGH);
}
setupScreen();
}
void loop() {
// draw the screen:
refreshScreen();
if(count-- == 0){
count = 40;
if(posX--==0){
posX = 7;
if(posY--==0){
posY = 7;
}
}
}
setupScreen();
}
void setupScreen(){
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = HIGH;
}
}
//OFF current pos
//pixels[posX][posY] = LOW;
pixels[5][3] = LOW;
pixels[1][7] = LOW;
}
void refreshScreen() {
thisPixel = pixels[5][3];
digitalWrite(row[5], HIGH);
digitalWrite(col[3], thisPixel);
digitalWrite(col[3], HIGH);
thisPixel2 = pixels[1][7];
digitalWrite(row[1], HIGH);
digitalWrite(col[7], thisPixel2);
}
Voici le résultat http://www.messinmaisoui.org/Arduino/_DSC0184.JPG
Note 3 : Bon je teste 2 leds, mais j'en ai allumé 4, ça s'explique sans doute
*par les croisements lignes/colonnes, ça c'est pas un soucis ... *
Ma question du jour ... c'est pourquoi ceci m'affiche une led brillante
=>
thisPixel = pixels[5][3];
digitalWrite(row[5], HIGH);
digitalWrite(col[3], thisPixel);
Alors que ceci me fait baisser la luminosité de la led en question !?
=>
thisPixel = pixels[5][3];
digitalWrite(row[5], HIGH);
digitalWrite(col[3], thisPixel);
digitalWrite(col[3], HIGH);
Ce qui est d'ailleurs pour moi (compte tenu de mon programme) équivalent à
=>
digitalWrite(row[5], HIGH);
digitalWrite(col[3], LOW);
digitalWrite(col[3], HIGH);
Et la led devrait s'éteindre mais ça n'est pas le cas :o ...
Merci pour votre aide précieuse