ATMEGA32 basic programming tutorial: In the following ATMEGA32 tutorial i used books to learn fundamental knowledge about Embedded system. After that i install Atmel Studio compiler and Proteus simulator tool to implement following basic ATMEGA32 programming tutorial:
Interfacing of keypad with ATMEGA32 : In this tutorial keypad is interfaced with AVR(ATMEGA32 ) controller. You need to enter password "1234#", you can use this tutorial for security checking projects. If you want to learn more kindly see tutorial on youtube as well.
>> keypad interface with ATMEGA32 C Code: /*****************Lcd.h*****************/ void cmd_lcd (unsigned char dat) // function to write command at lcd port { LCD=dat; RS=0; //clear RS (ie. RS=0) to write command E=1; // send H-L pulse at E pin delay_us(100); E=0; delay_us(100); }
void data_lcd (unsigned char dat) // function to write data at lcd port { LCD=dat; RS=1; // set RS=1 to write DATA E=1; // send H-L pulse at E pin delay_us(100); E=0; delay_us(100); }
void init_lcd() // function to initialize the LCD at power on time { cmd_lcd (0x38); // 2x16 display select delay_ms(50); cmd_lcd (0x0c); // display on cursor off command delay_ms(1); cmd_lcd (0x06); // automatic cursor movement to right delay_ms(1); cmd_lcd (0x01); // lcd clear command delay_ms(5); } void string_lcd(unsigned char *str) // function to display string to lcd { while(*str!='\0') // '\0' is null char as last char of pointer is null { data_lcd(*str); str++; } } /*****************Keypad.h*****************/ unsigned char keyscan() { while(1) { KEYPAD_PORT = 0XeF; delay_ms(10); /////must for response at porta when key press if((KEYPAD_PIN&0b00000001)==0){while((KEYPAD_PIN&0b00000001)==0); return '3';} if((KEYPAD_PIN&0b00000010)==0){while((KEYPAD_PIN&0b00000010)==0); return '2';} if((KEYPAD_PIN&0b00000100)==0){while((KEYPAD_PIN&0b00000100)==0); return '1';} if((KEYPAD_PIN&0b00001000)==0){while((KEYPAD_PIN&0b00001000)==0); return '0';}