Rabu, 03 Oktober 2012

APLIKASI ATMEGA16 UNTUK LCD






Berikut adalah cara membuat sample rangkaian dan program untuk LCD 16×2 menggunakan IC ATMega16.
Program yang digunakan:
1. Proteus ISIS 7
2. MikroC for AVR
Komponen yang digunakan dalam rangakaian:
1. IC ATMega16
2. Potensiometer
3. LCD 16×2
4. Crystal
Rangkaian seperti gambar diatas, sedangkan programnya ada di bawah ini:
sbit LCD_RS at PORTB.B2;
sbit LCD_EN at PORTB.B3;
sbit LCD_D4 at PORTB.B4;
sbit LCD_D5 at PORTB.B5;
sbit LCD_D6 at PORTB.B6;
sbit LCD_D7 at PORTB.B7;
sbit LCD_RS_Direction at DDRB.B2;
sbit LCD_EN_Direction at DDRB.B3;
sbit LCD_D4_Direction at DDRB.B4;
sbit LCD_D5_Direction at DDRB.B5;
sbit LCD_D6_Direction at DDRB.B6;
sbit LCD_D7_Direction at DDRB.B7;
char txt1[] = “Elektro 17″;
char txt2[] = “Mercu Buana”;
char txt3[] = “Contoh LCD”;
char txt4[] = “example”;
char i;
void Move_Delay() {
Delay_ms(500);
}
void main(){
Lcd_Init();
Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(1,6,txt3);
Lcd_Out(2,6,txt4);
Delay_ms(2000);
Lcd_Cmd(LCD_CLEAR);
Lcd_Out(1,1,txt1);
Lcd_Out(2,4,txt2);
Delay_ms(2000);
// Moving text
for(i=0; i<4; i++) {
Lcd_Cmd(LCD_SHIFT_RIGHT);
Move_Delay();
}
while(1) {
for(i=0; i<7; i++) {
Lcd_Cmd(LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=0; i<7; i++) {
Lcd_Cmd(LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}

0 komentar:

Posting Komentar

 
Copyright ELEKTRONICA MIKROKONTROLER All Rights Reserved
Powered by Alat Rekaman
ProSense theme created by Dosh Dosh and The Wrong Advices.
Blogerized by Bonard Alfin Forum Distorsi.