This project is, how to running the TEXT or moving from the current place to move to the left side then after few second stop then move back to current side, and looping for every each times.
This project for testing A LCD JM2001A with 1 line for 20 character, I founded A JM2001A having a problem with no light, something like led (Anode & Cathode) is dead, so when I want to test this LCD I don't have the device to see that LCD work or not, so I try to bulding this simple project to checking this LED and each character into LCD.
Below are the code for this project, and you can copy it for your LCD, but before you write this code or copy, you need to have the compiler to compile this, you can get this compiler as a free at MIKROELEKTRONIKA, also you need to have a programmer to flash this to your PIC16F877A :
You should know, this code using C language in Mikroelektronika Compiler.
/* RUNNING TEXT UNTUK TEST LCD JM20001A 1 LINE 20 KARAKTER */
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
char txt1[21] = "CSA SERVICE TEST-LCD"; // TEXT Yang Akan Di Tampilkan Dan Gerak-kan
char i; // Initial Karakter txt1
void tunda() { // Fungsi Tundaan Sebanyak 300 ms
Delay_ms(300);
}
void main(){
TRISD = 0x00 ;
PORTD = 0xFF ;
TRISB = 0x00;
PORTB = 0x00;
Lcd_Init(); // Initialisasi LCD
Lcd_Cmd(_LCD_CLEAR); // Bersihkan Layar
Lcd_Cmd(_LCD_CURSOR_OFF); // Matikan Kursor
Lcd_Out(1,1,txt1); // Tulis txt1 Pada baris Kolom 1 Dan Baris 1
Delay_ms(2000); // Selanjut nya Tunda Sebesar Nilai (2000 ms)
Lcd_Cmd(_LCD_CLEAR); // Bersihkan Layar
Lcd_Out(1,1,txt1); // Tuliskan txt1 Pada baris Kolom 1 Dan Baris 1
PORTB = 0b10000000; // Aktifkan RB7 Untuk LED Power
Delay_ms(2000);
// Mulai Gerak
for(i=0; i<20; i++) { // Gerakan Karakter Sebanyak 20 Kali
PORTD = 0b00000001 ; // Nyalakan RD0 Untuk LED
Lcd_Cmd(_LCD_SHIFT_RIGHT);
tunda(); // Tunda Sebanyak 300ms
}
Delay_ms(2000); // Setelah Karakter Hilang Dari Layar Tunda 2000ms
while(1) { // Ulangi Untuk Persiapan
for(i=0; i<20; i++) { // Gerakan Karakter Ke Kanan Sebanyak 20 Kali
Lcd_Cmd(_LCD_SHIFT_LEFT);
PORTD = 0b00000010 ; // Nyalakan RD1 Untuk LED
tunda(); // Tunda Sebanyak 300ms
}
Delay_ms(2000); // Setelah Karakter Hilang Dari Layar Tunda 2000ms
for(i=0; i<20; i++) { // Ulangi Seperti Diatas
PORTD = 0b00000001 ;
Lcd_Cmd(_LCD_SHIFT_RIGHT);
tunda();
}
}
}
Here is A Schematic using A PIC16F877A, this PIC you can find it at local store or online store in your country.
Below is a video