Dalam pembahasan kali ini bahwa kita dapat membuat karakter sendiri pada LCD 16X2 menggunakan Codevision AVR seperti bentuk Pacman, tampilan seperti pesawat pada Game Watch,dan selanjutnya menurut kreasi kita masing - masing.
Berikut tampilan karakter berbentuk Pesawat Game Watch :
Berikut tampilan karakter berbentuk Pacman :
Berikut videonya :
Dan ini potongan listing programnya :
#include
#include
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include
// Declare your global variables here
typedef unsigned char byte;
/* table for the user defined character
arrow that points to the top right corner */
flash byte char0[8]={
0b0000111,
0b0001110,
0b0011100,
0b1111000,
0b1111000,
0b0011100,
0b0001110,
0b0000111,
};
flash byte char1[8]={
0b0000110,
0b0001111,
0b0011111,
0b1111111,
0b1111111,
0b0011111,
0b0001111,
0b0000110,
};
flash byte char2[8]={
0b1110000,
0b0111000,
0b0001110,
0b1111111,
0b1111111,
0b0001110,
0b0111000,
0b1110000,
};
flash byte char3[8]={
0b0000000,
0b0000000,
0b0000000,
0b0001110,
0b0001110,
0b0000000,
0b0000000,
0b0000000,
};
flash byte char4[8]={
0b0001000,
0b0010010,
0b0000101,
0b0000110,
0b0010010,
0b0001011,
0b0010100,
0b0001001,
};
void define_char(byte flash *pc,byte char_code)
{
byte i,a;
a=(char_code<<3) | 0x40;
for (i=0; i<8; i++) lcd_write_byte(a++,*pc++);
}
int x,y;
void menu()
{
lcd_gotoxy(0,0);
lcd_putchar(0);
lcd_gotoxy(1,0);
lcd_putchar(1);
lcd_gotoxy(2,0);
lcd_putchar(2);
lcd_gotoxy(3,0);
lcd_putchar(3);
}
void main(void)
{
lcd_init(16);
define_char(char0,0);
define_char(char1,1);
define_char(char2,2);
define_char(char3,3);
define_char(char4,4);
while (1)
{
menu();
};
}
0 komentar:
Post a Comment
Please correct and comment