edu7
1
all works, except the first 0
char numero[10][7]={"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110000","1111111","1110011"};
byte puerto[14]={0,1,2,3,4,5,6,7,8,9,10,11,12,13};
void setup() {
byte i;
for (i=0; i<=14; i++)
pinMode(i, OUTPUT);
}
void loop() {
segdigito();
}
void pridigito(){
byte i=0;
byte p=0;
for(p=0;p<10;p++)
{
for(i=0;i<7;i++){
if(numero[p][i]=='1') digitalWrite(puerto[i], HIGH);
else digitalWrite(puerto[i], LOW);
}
delay(100);
}
}
void segdigito(){
byte i,p;
for(p=0;p<10;p++)
{
for(i=7;i<14;i++){
if(numero[p][i]=='1') digitalWrite(puerto[i], HIGH);
else digitalWrite(puerto[i], LOW);
}
pridigito();
}
}
J-M-L
2
when you do
char numero[10][7]={"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110000","1111111","1110011"};
the "1111110" (and others) are not stored on 7 bytes. this is a cString so there is a trailing '\0' that you don't see added by the compiler
If I were you I would check those indexes...
for(i=[color=red]7;i<14[/color];i++){
if(numero[p][color=red][ i][/color]=='1') digitalWrite(puerto[ i], HIGH);
else digitalWrite(puerto[ i], LOW);
}
you could just use const char * numero[] = {"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110000","1111111","1110011"};
What do you suppose that '1' - '0' is? What do you suppose that '0' - '0' is?
Instead of the 4 line if statement to determine whether to set the pin HIGH or LOW, and to actually do it:
digitalWrite(puerto[i], numero[p][i] - '0');
all works, except the first 0
You need to explain that, in a lot more detail.
Your blocks of characters are 7 characters long. Why are you using indexes 7 through 13?!? Did you intend to use "numero[p][i-7]"?
char numero[10][7]={"1111110","0110000","1101101","1111001","0110011","1011011","1011111","1110000","1111111","1110011"};
for(i=7;i<14;i++){
if(numero[p][i]=='1')
digitalWrite(puerto[i], HIGH);
else
digitalWrite(puerto[i], LOW);
}