LCD cgram com matriz |
Código feito em CCS C Compiler
#include <16F877A.h>
#use delay(clock = 20MHz)
#include <lcd.c>
#define LIN 12 // limite que a RAM consegue processar
#define COL 8
int matriz[LIN][COL] = {
{0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000},
{0b00000, 0b01000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000},
{0b00000, 0b01110, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000},
{0b00000, 0b01110, 0b00001, 0b00000, 0b00000, 0b00000, 0b00000},
{0b00000, 0b01110, 0b00001, 0b00001, 0b00001, 0b00000, 0b00000},
{0b00000, 0b01110, 0b00001, 0b00001, 0b00001, 0b00001, 0b00000},
{0b00000, 0b01110, 0b00001, 0b00001, 0b00001, 0b00001, 0b00010},
{0b00000, 0b01110, 0b00001, 0b00001, 0b00001, 0b00001, 0b01110},
{0b00000, 0b01110, 0b00001, 0b00001, 0b00001, 0b10001, 0b01110},
{0b00000, 0b01110, 0b00001, 0b00001, 0b10001, 0b10001, 0b01110},
{0b00000, 0b01110, 0b00001, 0b10001, 0b10001, 0b10001, 0b01110},
{0b00000, 0b01110, 0b10001, 0b10001, 0b10001, 0b10001, 0b01110}
};
void main(){
lcd_init();
while(TRUE){
/*
//matriz[0][i];
lcd_set_cgram_char(0, matriz[i]);
printf(lcd_putc, "\f%c \t\ni = %d", 0, i);
delay_ms(1000);
i++;
if(i >= LIN){ i = 0;}*/
for(int i = 0; i < COL; i++){
for(int j = 0; j < LIN; j++){
lcd_set_cgram_char(0, matriz[j]);
lcd_gotoxy(1, 1);
printf(lcd_putc, "\f%c \t[%d][%d]", 0, i, j);
delay_ms(500);
}
}
}
}
Nenhum comentário:
Postar um comentário