Loading

Kategory:

AVR RUNNING TEXT ON 16X2 HD44780 LCD – (CodeVision AVR)

Bookmark and Share
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.
AVR RUNNING TEXT ON 16X2 HD44780 LCD – (CodeVision AVR)
*/
//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 <mega8535.h>
 
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x1B ;PORTA
   //.equ __lcd_port=0x15 ;PORTC
#endasm
 
// Standard Input/Output functions
#include <lcd.h>
#include <delay.h>  
#include <string.h>
 
// Global variables
// Silahkan ganti text yang mau ditampilin di array buffer_lcd
char buffer_lcd[]="RUNNING TEXT ON 2X16 HD44780 LCD.. Coded by: "
"Herlambang Aribowo :D http://www.nubielab.com               ";//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  = strlen(buffer_lcd);
_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)
    };     
}
Dan ini adalah screenshot dari simulasi proteus..
AVR RUNNING TEXT ON 16X2 HD44780 LCD – (CodeVision AVR)

Yang perlu diingat.. kode ini ane bikin dengan compiler CVAVR 2.03.9. kalau diganti versi kompiler… apalagi downgrade, ane gak menjamin kode ini bisa berjalan dengan semestinya.
Thanks..

AVR RUNNING TEXT ON 16X2 HD44780 LCD – (CodeVision AVR)
Thanks for reading: AVR RUNNING TEXT ON 16X2 HD44780 LCD – (CodeVision AVR)
Related Posts Plugin for WordPress, Blogger...