Coba Test Source Code Di bawah Ini.
Semoga Bermanfaat.
/******************************************************************************
' Name Project : Penghitungan Nomor Antrian '
' Microcontroller : PIC16F877A '
' Crystal : 4 Mhz '
' Copyright : 2010@RWorotikan '
' Revision : 2013@RWorotikan '
******************************************************************************/
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 PS_1[]="NOMOR ANTRIAN";
char PS_2[]="LOKET -> 1" ;
char PS_3[]="LOKET -> 2" ;
char PS_4[]="LOKET -> 3" ;
char PS_5[]="LOKET -> 4" ;
char PS_6[]="LOKET -> 5" ;
unsigned int angka = 0;
char *digit = "000";
void Tunda(){
Delay_ms(280);
}
void Tampilan_nilai()
{
digit[0] = (angka/100)%10 +48;
digit[1] = (angka/10)%10 + 48;
digit[2] = angka%10 +48;
Lcd_Out(2,1,digit);
}
void main()
{
CMCON = 0x07;
TRISB = 0x00;
PORTB = 0xC0;
TRISC = PORTC = 0b11111111 ;
TRISD = PORTD = 0xFF ;
Lcd_init();
Lcd_cmd(_LCD_CLEAR);
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,PS_1);
Delay_ms(2600) ;
PORTD = 0x00 ;
do{
if(Button(&PORTC,2,0,0)){
Tunda() ;
angka = angka +1;
Lcd_out(1,1,PS_1);
Lcd_out(2,7,PS_2);
PORTD = 0x01 ;
}
if(Button(&PORTC,4,0,0)){
Tunda() ;
angka = angka +1;
Lcd_out(1,1,PS_1);
Lcd_out(2,7,PS_3);
PORTD = 0x02 ;
}
if(Button(&PORTC,5,0,0)){
Tunda() ;
angka = angka +1;
Lcd_out(1,1,PS_1);
Lcd_out(2,7,PS_4);
PORTD = 0x04 ;
}
if(Button(&PORTC,6,0,0)){
Tunda() ;
angka = angka +1;
Lcd_out(1,1,PS_1);
Lcd_out(2,7,PS_5);
PORTD = 0x08 ;
}
if(Button(&PORTC,7,0,0)){
Tunda() ;
angka = angka +1;
Lcd_out(1,1,PS_1);
Lcd_out(2,7,PS_6);
PORTD = 0x10 ;
}
if(Button(&PORTC,3,0,0)){
Tunda() ;
angka = angka -1;
Lcd_cmd(_LCD_CLEAR);
Lcd_out(1,1,PS_1);
PORTD = 0x00 ;
}
if (angka > 500 )
angka = 0;
Tampilan_nilai();
} while(1);
}