Presentation is loading. Please wait.

Presentation is loading. Please wait.

A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p (130010111001) Guided by, Prof. Asif Thakor.

Similar presentations


Presentation on theme: "A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p (130010111001) Guided by, Prof. Asif Thakor."— Presentation transcript:

1 A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p (130010111001) Guided by, Prof. Asif Thakor.

2 contents Introduction to AVR Board. Introduction to LCD. Introduction to Keyboard. Connection diagram. Program. Conclusion.

3 Introduction to AVR Board. We have AVR general purpose mother board which is shown in fig 1.1 It has Microcontroller AVR ATMEGA32 which is very power full controller with 4 PORTS on board. We can use female header to connect any device with Board. This Board is USBISP compatible that means we can program our IC by using simple USBASP AVR Programmer, Just Connect ISP pin to the board and connect to PC with suitable Driver and Program.hex File using any AVR Dude Gui Programmer. This Board has dual Power supply 1)By Adapter 2) By Connecting usbasp. This Board has RS232 Port also that means we can Transfer data in full duplex mode via PC To uC or uC to PC. We will connect 2×2 Matrix keyboard to Port B0 1 2 3 and 16×2 LCD to PORT D.

4

5 Introduction to LCD. Here we have 16×2 LCD It has 2lines and 16charachters per each line LCD has 16 Pin in that Pin 1,2,3:It is VSS GND and VCC,Vcc=5V,VSS=GND=0V. Pin 4,5,6:It is RS,R/W and EN Give Rs=0 for command Register. Rs=1 for Data register. R/w=0 For writing data into register En=Falling edge to enable latch. Pin 7-14:Data Pins. Pin 15,16:LCD back light.

6

7 Introduction to Keyboard

8 As Shown in fig the it is 4by4 matrix keyboard as shown in fig to scan which key has been pressed first we have to give a 0000 to all raws and check any key has been pressed by columns by scanning 1 if condition false then give 20ms debouncing time period and give again 0000 to all raws and scan whether any key has been pressed. To scan all keys follow the below steps First make B0pin =0 and B1 pin=1 and scan Pin B2 and B3. If pinb2 =0 and pinb3=1 it will be print ‘0’ on screen of LCD. If pinb2=1 and pinb3=0 it will be print ‘1’ on screen of LCD. Second make B0 pin=1and B1 pin=0 and scan Pin B2 and B3. If pinb2 =0 and pinb3=1 it will be print ‘2’ on screen of LCD. If pinb2=1 and pinb3=0 it will be print ‘3’ on screen of LCD.

9 schematic

10 Inside LCD1.h File void lcd_command(unsigned char z) { PORTD=z; msdelay(1); PORTB&=~(1<<5); msdelay(1); PORTB&=~(1<<6); msdelay(1); PORTB|=(1<<7); msdelay(1); PORTB&=~(1<<7); msdelay(1); } void lcd_data(unsigned char m) { PORTD=m; msdelay(1); PORTB=1; msdelay(1); PORTB&=~(1<<6); msdelay(1); PORTD|=(1<<7); msdelay(1); PORTD&=~(1<<7); msdelay(1); }

11 void lcd_init(void) { DDRD=DDRB=0XFF; msdelay(1); lcd_command(0X38); msdelay(1); lcd_command(0X0E); msdelay(1); lcd_command(0X01); msdelay(1); } void lcd_string(unsigned char s[]) { unsigned char i=0,j=0X80,k; k=strlen(s); for(i=0;i<k;i++) { lcd_command(j); msdelay(1); lcd_data(s[i]); msdelay(1); j++; } return(0); }

12 Main Program #include #include "lcd1.h" void check(unsigned char m) int main() { lcd_init(); unsigned char raw; unsigned char t[2][2]={'0','1', '2','3'}; while(1) { PORTB&=0XFC; while((PINB&0X0C)==0X0C); msdelay(20); while((PINB&0X0C)==0X0C); raw=0; PORTB&=~(1<<0); PORTB|=(1<<1); check(raw); raw=1; PORTB&=~(1<<1); PORTB|=(1<<0); check(raw); }

13 Check function void check(unsigned char m) { if((PINB&0X0C)==0X08) { lcd_command(0X80); lcd_data(t[m][0]); } if((PINB&0X0C)==0X04) { lcd_command(0X80); lcd_data(t[m][1]); }

14 Conclusion From this we have seen that as we press key that corresponding key will displayed on LCD display as ‘0’ ‘1’ ‘2’ ‘3’ etc.

15 Thank you


Download ppt "A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p (130010111001) Guided by, Prof. Asif Thakor."

Similar presentations


Ads by Google