You are on page 1of 4

AVR RUNNING TEXT ON 16X2 (CodeVision AVR)

Program penampil LCD dengan LCD 16X2 HD44780 based controller. Program ini akan menampilkan tulisan berjalan kekiri. Dibuat dengan CodeVision AVR V.2.03.9. Program juga dilengkapi dengan simulasi menggunakan Proteus ISIS Simulation. Buka file *.DSN dengan proteus V7.4 SP 3 atau yang lebih baru. Silahkan dimanfaatkan untuk belajar dan bila ada pertanyaan, kritik atau saran post aja di kolom komentar. Atau bisa dengan mengirimkan email ke zulfanputra@yahoo.com Semoga bermanfaat. listing programnya:
//Simple running text on 2X16 HD44780 LCD.. for AVR (Codevision AVR) //you can modify this source code for your specific needs. //You should recompile this code using CodeVision AVR V2.03.9 or later. //This code is distributed under GNU license. //For question and suggestion you should contact me on the address above. //Happy programming :D /************************************************************************* this file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Copyright 2009, 2010 Herlambang Aribowo ************************************************************************/ #include // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x1B ;PORTA //.equ __lcd_port=0x15 ;PORTC #endasm // Standard Input/Output functions

#include #include #include // Global variables // Silahkan ganti text yang mau ditampilin di array buffer_lcd char buffer_lcd[]="RUNNING TEXT ON 2X16 HD44780 LCD.. Coded by: " "tulis nama anda ";//space required // belakang sendiri kasih karakter "spasi"/0x20 biar keliatan fadingnya. char lcd_number = 16; //diganti sesuai kebutuhan misal pake yg 4x20 //lcd_number = 20 // Function prototype void sett_regs(void); void tampilan(void); // Main routine (super loop) void main(void){ sett_regs(); lcd_init(16); _lcd_ready(); lcd_clear(); for(;;){// Endless loop, podo karo "while(1)" tampilan(); } } // Setting register void sett_regs(void){ //Define I/O

DDRA = 0xff;PORTA = 0x00; DDRB = 0x00;PORTB = 0x00; DDRC = 0x00;PORTC = 0x00; } // Display routine :D void tampilan(void){ unsigned int i,j,k; unsigned int data_len; _lcd_ready(); lcd_clear(); lcd_gotoxy(0,0); lcd_putsf(" RUNNING TEXT "); for (i=lcd_number; i>=0; --i){ if (i > lcd_number)break; lcd_gotoxy(i,1); for (j=0; j<(lcd_number-i); j++){ lcd_putchar(buffer_lcd[j]); } delay_ms(100); //ubah untuk kecepatan pergeseran text }; k=0; for (i=0; i<=data_len; i++){ k++; lcd_gotoxy(0,1); for (j=0; j<16; j++){ if (buffer_lcd[j+k] == NULL){

return; } lcd_putchar(buffer_lcd[j+k]); } delay_ms(100); //ubah untuk kecepatan pergeseran text (samakan sama yang diatas) }; }

You might also like