salu merci de ta reponse.
j'ai reglé le probleme du for et j'ai changer les variable sauf que sa ne fait pas ce que je cherche,je veux afficher un smile mais tout les point lumineux s'allume.
voila mon code:
const int rownum [5] = {13, 12, 11, 10, 9};
const int colnum [5] = {7, 6, 5, 4, 3};
int timeCount;
int smile[5][5] = {
{0,1,0,1,0},
{0,1,0,1,0},
{0,1,0,1,0},
{1,0,0,0,1},
{0,1,1,1,0}};
int tp;
int br;
int bc;
void setup()
{
Serial.begin(9600);
for (tp=0;tp <5;tp++){
pinMode(rownum[tp], OUTPUT);
pinMode(colnum[tp], OUTPUT);
digitalWrite(colnum[tp], LOW);
digitalWrite(rownum[tp], HIGH);
}
}
void loop()
{
delay(5);
drawScreen(smile);
}
int row(int i) {
if(i == 1) {
return 13;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 11;
} else if (i == 4) {
return 10;
} else if (i == 5) {
return 9;
}
}
int col(int i) {
if(i == 1) {
return 7;
} else if (i == 2) {
return 6;
} else if (i == 3) {
return 5;
} else if (i == 4) {
return 4;
} else if (i == 5) {
return 3;
}
}
void drawScreen(int character[5][5])
{
for(int j = 0; j < 8; j++) {
// Turn the row on
int rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (int k = 0; k < 8; k++) {
int columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}
digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}
et celui du site:
const int rownum[8] = {
10,12,15,17,2,4,6,8 };
// 2-dimensional array of column pin numbers:
const int colnum[8] = {
11,14,16,18,3,5,7,9 };
float timeCount = 0;
int h[8][8] = {
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0}};
int e[8][8] = {
{0,0,1,1,1,1,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,1,1,1,0},
{0,0,0,0,1,1,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,1,1,1,1,1,0}};
int l[8][8] = {
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,1,1,1,1,1,0}};
int o[8][8] = {
{0,0,0,1,1,1,0,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,0,1,1,1,0,0}};
int smile[8][8] = {
{0,0,0,0,0,0,0,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,0,0,0,0,0,0,0},
{0,1,0,0,0,0,1,0},
{0,0,1,0,0,1,0,0},
{0,0,0,1,1,0,0,0}};
int blank[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}};
void setup() {
Serial.begin(9600);
// initialize the I/O pins as outputs:
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(colnum[thisPin], OUTPUT);
pinMode(rownum[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(colnum[thisPin], LOW);
digitalWrite(rownum[thisPin], HIGH);
}
}
void loop() {
// This could be rewritten to not use a delay, which would make it appear brighter
delay(5);
timeCount += 1;
if(timeCount < 200) {
drawScreen(h);
} else if (timeCount < 230) {
// do nothing
} else if (timeCount < 400) {
drawScreen(e);
} else if (timeCount < 430) {
// nothing
} else if (timeCount < 600) {
drawScreen(l);
} else if (timeCount < 630) {
// nothing
} else if (timeCount < 800) {
drawScreen(l);
} else if (timeCount < 830) {
// nothing
} else if (timeCount < 1000) {
drawScreen(o);
} else if (timeCount < 1030) {
// nothing
} else if (timeCount < 1200) {
drawScreen(smile);
} else if (timeCount < 1230) {
// nothing
} else {
// back to the start
timeCount = 0;
}
}
int row(int i) {
if(i == 1) {
return 10;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 15;
} else if (i == 4) {
return 17;
} else if (i == 5) {
return 2;
} else if (i == 6) {
return 4;
} else if (i == 7) {
return 6;
} else if (i == 8 ) {
return 8;
}
}
int col(int i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8 ) {
return 9;
}
}
void drawScreen(int character[8][8]) {
for(int j = 0; j < 8; j++) {
// Turn the row on
int rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (int k = 0; k < 8; k++) {
// draw some letter bits
int columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}
digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}