unsigned char string_1[] PROGMEM = {0x00,0xFF,0xFF,0xFF,0x00,0x00,0xC3,0xDB,0XDB,0XDB,0XFF,0XFF,0X00,0X00,0XC0,0XD8,0XD8,0XD8,0XFF,0XFF};
unsigned char string_2[] PROGMEM = {0xFF,0x0C0,0x08,0x0D6,0x0BF,0x0F8,0x01,0x0A,0X53,0xFF};
PROGMEM unsigned char* imagens[] = { string_1, string_2 };
int ttbytes[] PROGMEM = { 20 , 10 };
for (int numero = 0;numero<2;numero++){
int tbytes = pgm_read_byte(&ttbytes[numero]);
unsigned char d;
for( int e = 0;e < tbytes;e++) {
d = pgm_read_byte(&imagens[numero][e]);
Serial.print(d,HEX);Serial.print(" ");
}
}
queria saber por que quando eu escrevo dessa forma acima, nao funciona. os dados saem errados, mas se eu escrever assim:
d = pgm_read_byte(&imagens[0][e]);
ou
d = pgm_read_byte(&imagens[1][e]);
ele sai certo?
Tags:
já tentou usar byte numero ao invés de int numero? int são dois bytes...
tentei.. nao funcionou...
testei aqui deu certo, você errou na posição do PROGMEM:
unsigned char string_1[] PROGMEM = {0x00,0xFF,0xFF,0xFF,0x00,0x00,0xC3,0xDB,0XDB,0XDB,0XFF,0XFF,0X00,0X00,0XC0,0XD8,0XD8,0XD8,0XFF,0XFF};
unsigned char string_2[] PROGMEM = {0xFF,0x0C0,0x08,0x0D6,0x0BF,0x0F8,0x01,0x0A,0X53,0xFF};unsigned char* PROGMEM imagens[] = { string_1, string_2 };
int ttbytes[] PROGMEM = { 20 , 10 };
for (int numero = 0;numero<2;numero++){
int tbytes = pgm_read_byte(&ttbytes[numero]);
unsigned char d;
for( int e = 0;e < tbytes;e++) {
d = pgm_read_byte(&imagens[numero][e]);
Serial.print(d,HEX);Serial.print(" ");
}}
Obrigado.. deu certo agora....
eu tinha feito igual o do site do arduino.cc onde ele fala do progmem , nem imaginava que isso estava errado. mas de qqr forma funcionou.. vlw
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por