LCD PIC
19.101. Rangkaian Simulasi [kembali]
2. Flowchart [kembali]
3. Listing Program [kembali]
sbit LCD_RS at RB5_bit;
sbit LCD_RW at RB4_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit; //Pendeklarasian pin untuk LCD
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_RW_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main() //Fungsi utama PIC
{
TRISC=0X03; // Port D0 dan D1 berfungsi sebagai input
PORTC=0X00; // Kondisi awal pada port D berkondisi low
Lcd_Init(); // Deklarasi LCD
Lcd_Cmd(_LCD_CLEAR); //LCD diclear (dibersihkan)
Lcd_Cmd(_LCD_CURSOR_OFF); //Pada LCD tidak menampilkan kursor
while(1) //Kondisi perulangan
{
if(PORTC.RC0==0) //Apabila port D0 diberi kondisi HIGH
{
Lcd_Out(1,1,"Selamat"); //LCD akan menampilkan tulisan "Selamat"
}
if(PORTC.RC1==0) //Apabila port D1 diberi kondisi HIGH
{
Lcd_Out(2,1,"Praktikum ^_^"); //LCD akan menampilkan tulisan " Praktikum ^_^"
}
}
}
sbit LCD_RW at RB4_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit; //Pendeklarasian pin untuk LCD
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_RW_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main() //Fungsi utama PIC
{
TRISC=0X03; // Port D0 dan D1 berfungsi sebagai input
PORTC=0X00; // Kondisi awal pada port D berkondisi low
Lcd_Init(); // Deklarasi LCD
Lcd_Cmd(_LCD_CLEAR); //LCD diclear (dibersihkan)
Lcd_Cmd(_LCD_CURSOR_OFF); //Pada LCD tidak menampilkan kursor
while(1) //Kondisi perulangan
{
if(PORTC.RC0==0) //Apabila port D0 diberi kondisi HIGH
{
Lcd_Out(1,1,"Selamat"); //LCD akan menampilkan tulisan "Selamat"
}
if(PORTC.RC1==0) //Apabila port D1 diberi kondisi HIGH
{
Lcd_Out(2,1,"Praktikum ^_^"); //LCD akan menampilkan tulisan " Praktikum ^_^"
}
}
}
4. Video [kembali]