پاسخ : سوال جالب و کاربردی در رابطه با چرخاندن کاراکترهای LCD2*16
سلام
به لینک زیر یه سری بزنید
لینک
:read:
سلام
به لینک زیر یه سری بزنید
لینک
:read:
/***************************************************** Author : Saman.Asadi Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega8.h> #include <alcd.h> #include <delay.h> #define byte unsigned char flash byte char_0[8]={16,0,0,0,0,0,0,0}; flash byte char_1[8]={20,0,0,0,0,0,0,0}; flash byte char_2[8]={21,0,0,0,0,0,0,0}; flash byte char_3[8]={21,8,0,0,0,0,0,0}; flash byte char_4[8]={21,10,0,0,0,0,0,0}; flash byte char_5[8]={21,10,16,0,0,0,0,0}; flash byte char_6[8]={21,10,20,0,0,0,0,0}; flash byte char_7[8]={21,10,21,0,0,0,0,0}; flash byte char_8[8]={21,10,21,8,0,0,0,0}; flash byte char_9[8]={21,10,21,10,0,0,0,0}; flash byte char_10[8]={21,10,21,10,16,0,0,0}; flash byte char_11[8]={21,10,21,10,20,0,0,0}; flash byte char_12[8]={21,10,21,10,21,0,0,0}; flash byte char_13[8]={21,10,21,10,21,8,0,0}; flash byte char_14[8]={21,10,21,10,21,10,0,0}; flash byte char_15[8]={21,10,21,10,21,10,16,0}; flash byte char_16[8]={21,10,21,10,21,10,20,0}; flash byte char_17[8]={21,10,21,10,21,10,21,0}; flash byte char_18[8]={21,10,21,10,21,10,21,8}; flash byte char_19[8]={21,10,21,10,21,10,21,10}; 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++); } void main(void) { // Alphanumeric LCD initialization // Connections are specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTB Bit 0 // RD - PORTB Bit 1 // EN - PORTB Bit 2 // D4 - PORTB Bit 4 // D5 - PORTB Bit 5 // D6 - PORTB Bit 6 // D7 - PORTB Bit 7 // Characters/line: 16 lcd_init(16); ////////////////////////////////////////////// define_char(char_0,0); define_char(char_1,1); define_char(char_2,2); define_char(char_3,3); define_char(char_4,4); define_char(char_5,5); define_char(char_6,6); define_char(char_7,7); lcd_clear(); lcd_putchar(0); delay_ms(300); lcd_putchar(1); delay_ms(300); lcd_putchar(2); delay_ms(300); lcd_putchar(3); delay_ms(300); lcd_putchar(4); delay_ms(300); lcd_putchar(5); delay_ms(300); lcd_putchar(6); delay_ms(300); lcd_putchar(7); delay_ms(300); //////////////////////////////////////////// define_char(char_8,0); delay_ms(300); define_char(char_9,1); delay_ms(300); define_char(char_10,2); delay_ms(300); define_char(char_11,3); delay_ms(300); define_char(char_12,4); delay_ms(300); define_char(char_13,5); delay_ms(300); define_char(char_14,6); delay_ms(300); define_char(char_15,7); delay_ms(300); ///////////////////////////////////////////// lcd_gotoxy(8,0); lcd_putchar(0); delay_ms(300); lcd_putchar(1); delay_ms(300); lcd_putchar(2); delay_ms(300); lcd_putchar(3); delay_ms(300); lcd_putchar(4); delay_ms(300); lcd_putchar(5); delay_ms(300); lcd_putchar(6); delay_ms(300); lcd_putchar(7); delay_ms(300); lcd_gotoxy(0,1); while (1); }
/***************************************************** Author : Saman.Asadi Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega8.h> #include <alcd.h> #include <delay.h> #define byte unsigned char flash byte char_0[8]={16,0,0,0,0,0,0,0}; flash byte char_1[8]={20,0,0,0,0,0,0,0}; flash byte char_2[8]={21,0,0,0,0,0,0,0}; flash byte char_3[8]={21,8,0,0,0,0,0,0}; flash byte char_4[8]={21,10,0,0,0,0,0,0}; flash byte char_5[8]={21,10,16,0,0,0,0,0}; flash byte char_6[8]={21,10,20,0,0,0,0,0}; flash byte char_7[8]={21,10,21,0,0,0,0,0}; flash byte char_8[8]={21,10,21,8,0,0,0,0}; flash byte char_9[8]={21,10,21,10,0,0,0,0}; flash byte char_10[8]={21,10,21,10,16,0,0,0}; flash byte char_11[8]={21,10,21,10,20,0,0,0}; flash byte char_12[8]={21,10,21,10,21,0,0,0}; flash byte char_13[8]={21,10,21,10,21,8,0,0}; flash byte char_14[8]={21,10,21,10,21,10,0,0}; flash byte char_15[8]={21,10,21,10,21,10,16,0}; flash byte char_16[8]={21,10,21,10,21,10,20,0}; flash byte char_17[8]={21,10,21,10,21,10,21,0}; flash byte char_18[8]={21,10,21,10,21,10,21,8}; flash byte char_19[8]={21,10,21,10,21,10,21,10}; 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++); } void main(void) { // Alphanumeric LCD initialization // Connections are specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTB Bit 0 // RD - PORTB Bit 1 // EN - PORTB Bit 2 // D4 - PORTB Bit 4 // D5 - PORTB Bit 5 // D6 - PORTB Bit 6 // D7 - PORTB Bit 7 // Characters/line: 16 lcd_init(16); ////////////////////////////////////////////// define_char(char_0,0); define_char(char_1,1); define_char(char_2,2); define_char(char_3,3); define_char(char_4,4); define_char(char_5,5); define_char(char_6,6); define_char(char_7,7); lcd_clear(); lcd_putchar(0); delay_ms(300); lcd_putchar(1); delay_ms(300); lcd_putchar(2); delay_ms(300); lcd_putchar(3); delay_ms(300); lcd_putchar(4); delay_ms(300); lcd_putchar(5); delay_ms(300); lcd_putchar(6); delay_ms(300); lcd_putchar(7); delay_ms(300); //////////////////////////////////////////// define_char(char_8,0); delay_ms(300); define_char(char_9,1); delay_ms(300); define_char(char_10,2); delay_ms(300); define_char(char_11,3); delay_ms(300); define_char(char_12,4); delay_ms(300); define_char(char_13,5); delay_ms(300); define_char(char_14,6); delay_ms(300); define_char(char_15,7); delay_ms(300); ///////////////////////////////////////////// lcd_gotoxy(8,0); lcd_putchar(0); delay_ms(300); lcd_putchar(1); delay_ms(300); lcd_putchar(2); delay_ms(300); lcd_putchar(3); delay_ms(300); lcd_putchar(4); delay_ms(300); lcd_putchar(5); delay_ms(300); lcd_putchar(6); delay_ms(300); lcd_putchar(7); delay_ms(300); lcd_gotoxy(0,1); while (1); }
دیدگاه