Bonjour à tous !
Même si je fais de la programmation web, je débute en C++ et Arduino.
Je cherche à afficher des lettres sur une matrice 8x8 à l'aide d'un MCP23017.
Il me semble que le code est correct mais quelque-chose doit m’échapper...
#include <Wire.h>
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp;
int tempsDebut = millis();
IRrecv irrecv(RECV_PIN);
decode_results results;
int a = 1;
int b = 1;
// config écran
#define nb_lignes 8
#define nb_colonnes 8
const bool** bin_A[nb_lignes][nb_colonnes] = {
{1,1,1,0,0,1,1,1},
{1,1,0,1,1,0,1,1},
{1,1,0,1,1,0,1,1},
{1,0,1,1,1,1,0,1},
{1,0,0,0,0,0,0,1},
{1,0,1,1,1,1,0,1},
{1,0,1,1,1,1,0,1},
{1,0,1,1,1,1,0,1},
};
/*
// display array
const byte tab_binaires[][nb_colonnes] = {
bin_NULL,
bin_A,
};
*/
const int ligne1 = 7; // the number of the row pin 9
const int ligne2 = 2; // the number of the row pin 1
const int ligne3 = 8; // the number of the row pin 13
const int ligne4 = 4; // the number of the row pin 12
const int ligne5 = 15; // the number of the row pin 1
const int ligne6 = 9; // the number of the row pin 7
const int ligne7 = 14; // the number of the row pin 2
const int ligne8 = 11; // the number of the row pin 5
//the pin to control COl
const int col1 = 3; // the number of the col pin 13
const int col2 = 13; // the number of the col pin 3
const int col3 = 12; // the number of the col pin 4
const int col4 = 6; // the number of the col pin 10
const int col5 = 10; // the number of the col pin 6
const int col6 = 5; // the number of the col pin 11
const int col7 = 1; // the number of the col pin 15
const int col8 = 0; // the number of the col pin 16
void afficher(bool **caractere)
{
for (int numLigne = 0 ; numLigne < nb_lignes ; numLigne++) {
mcp.digitalWrite(col1, caractere[numLigne][0]);
mcp.digitalWrite(col2, caractere[numLigne][1]);
mcp.digitalWrite(col3, caractere[numLigne][2]);
mcp.digitalWrite(col4, caractere[numLigne][3]);
mcp.digitalWrite(col5, caractere[numLigne][4]);
mcp.digitalWrite(col6, caractere[numLigne][5]);
mcp.digitalWrite(col7, caractere[numLigne][6]);
mcp.digitalWrite(col8, caractere[numLigne][7]);
Serial.print("LIGNE ");
Serial.print(numLigne+1);
Serial.println(" :");
Serial.print("Col1 : ");
Serial.println(caractere[numLigne][0]);
Serial.print("Col2 : ");
Serial.println(caractere[numLigne][1]);
Serial.print("Col3 : ");
Serial.println(caractere[numLigne][2]);
Serial.print("Col4 : ");
Serial.println(caractere[numLigne][3]);
Serial.print("Col5 : ");
Serial.println(caractere[numLigne][4]);
Serial.print("Col6 : ");
Serial.println(caractere[numLigne][5]);
Serial.print("Col7 : ");
Serial.println(caractere[numLigne][6]);
Serial.print("Col8 : ");
Serial.println(caractere[numLigne][7]);
switch (numLigne)
{
case 0: mcp.digitalWrite(ligne1, 1); break;
case 1: mcp.digitalWrite(ligne2, 1); break;
case 2: mcp.digitalWrite(ligne3, 1); break;
case 3: mcp.digitalWrite(ligne4, 1); break;
case 4: mcp.digitalWrite(ligne5, 1); break;
case 5: mcp.digitalWrite(ligne6, 1); break;
case 6: mcp.digitalWrite(ligne7, 1); break;
case 7: mcp.digitalWrite(ligne8, 1); break;
default: break;
}
switch (numLigne)
{
case 0: mcp.digitalWrite(ligne1, 0); break;
case 1: mcp.digitalWrite(ligne2, 0); break;
case 2: mcp.digitalWrite(ligne3, 0); break;
case 3: mcp.digitalWrite(ligne4, 0); break;
case 4: mcp.digitalWrite(ligne5, 0); break;
case 5: mcp.digitalWrite(ligne6, 0); break;
case 6: mcp.digitalWrite(ligne7, 0); break;
case 7: mcp.digitalWrite(ligne8, 0); break;
default: break;
}
mcp.digitalWrite(col1, 0);
mcp.digitalWrite(col2, 0);
mcp.digitalWrite(col3, 0);
mcp.digitalWrite(col4, 0);
mcp.digitalWrite(col5, 0);
mcp.digitalWrite(col6, 0);
mcp.digitalWrite(col7, 0);
mcp.digitalWrite(col8, 0);
}
}
void setup() {
mcp.begin();
int i = 0 ;
for (i = 0; i < 16; i++)
{
mcp.pinMode(i, OUTPUT);
}
for (i = 0; i < 16; i++) {
mcp.digitalWrite(i, 0);
}
Serial.begin(9600);
}
void loop() {
afficher(**bin_A);
}
Voici le résultat du Serial Print :
LIGNE 1 :
Col1 : 45
Col2 : 0
Col3 : 32
Col4 : 0
Col5 : 207
Col6 : 0
Col7 : 0
Col8 : 0
LIGNE 2 :
Col1 : 45
Col2 : 0
Col3 : 32
Col4 : 0
Col5 : 0
Col6 : 0
Col7 : 0
Col8 : 0
LIGNE 3 :
Col1 : 45
Col2 : 0
Col3 : 32
Col4 : 0
Col5 : 0
Col6 : 0
Col7 : 0
Col8 : 0
LIGNE 4 :
Col1 : 197
Col2 : 182
Col3 : 60
Col4 : 26
Col5 : 191
Col6 : 207
Col7 : 185
Col8 : 238
LIGNE 5 :
Col1 : 220
Col2 : 255
Col3 : 61
Col4 : 130
Col5 : 107
Col6 : 202
Col7 : 219
Col8 : 206
LIGNE 6 :
Col1 : 249
Col2 : 159
Col3 : 23
Col4 : 94
Col5 : 159
Col6 : 159
Col7 : 104
Col8 : 235
LIGNE 7 :
Col1 : 249
Col2 : 159
Col3 : 23
Col4 : 94
Col5 : 159
Col6 : 159
Col7 : 104
Col8 : 235
LIGNE 8 :
Col1 : 170
Col2 : 28
Col3 : 223
Col4 : 159
Col5 : 106
Col6 : 193
Col7 : 221
Col8 : 228
Alors que je devrais n'avoir que des 0 et des 1...
Merci d'avance pour votre aide !