Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LCD module connections
- 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;
- // End LCD module connections
- TRISC.B2 = 0;
- PORTC.B2 = 0;
- char keypadPort at PORTD;
- char kp;
- int password;
- void main (){
- Lcd_Init ();
- Keypad_Init ();
- Lcd_Cmd(_LCD_CLEAR); // Clear display
- Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
- Lcd_Out(2,5,"pressed");
- try_again:
- while(1){
- kp=0;
- password =0;
- while(!kp){kp = Keypad_Key_Press();}
- switch (kp){
- case 1: kp = 7; break; // 1 // Uncomment this block for keypad4x4
- case 2: kp = 8; break; // 2
- case 3: kp = 9; break; // 3
- case 5: kp = 4; break; // 4
- case 6: kp = 5; break; // 5
- case 7: kp = 6; break; // 6
- case 9: kp = 1; break; // 7
- case 10: kp = 2; break; // 8
- case 11: kp = 3; break; // 9
- case 13:
- goto omnia;
- break;
- case 14: kp = 48; break; // 0
- }
- password = password * 10 + kp;
- }
- omnia : if(password == 1234)
- {
- PORTC.B2 = 1;
- LCD_Cmd(_LCD_CLEAR);
- LCD_Out_Cp("Openning...");
- }
- else
- {
- PORTC.B2 = 0;
- LCD_Cmd(_LCD_CLEAR);
- LCD_out_cp("Emsek Haramy");
- goto try_again;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment