AnonymousEng

Omnia

Jul 5th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1.    // LCD module connections
  2. sbit LCD_RS at RB4_bit;
  3. sbit LCD_EN at RB5_bit;
  4. sbit LCD_D4 at RB0_bit;
  5. sbit LCD_D5 at RB1_bit;
  6. sbit LCD_D6 at RB2_bit;
  7. sbit LCD_D7 at RB3_bit;
  8.  
  9. sbit LCD_RS_Direction at TRISB4_bit;
  10. sbit LCD_EN_Direction at TRISB5_bit;
  11. sbit LCD_D4_Direction at TRISB0_bit;
  12. sbit LCD_D5_Direction at TRISB1_bit;
  13. sbit LCD_D6_Direction at TRISB2_bit;
  14. sbit LCD_D7_Direction at TRISB3_bit;
  15. // End LCD module connections
  16. TRISC.B2 = 0;
  17. PORTC.B2 = 0;
  18. char keypadPort at PORTD;
  19. char kp;
  20. int password;
  21. void main (){
  22.  
  23. Lcd_Init ();
  24. Keypad_Init ();
  25. Lcd_Cmd(_LCD_CLEAR);               // Clear display
  26. Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  27. Lcd_Out(2,5,"pressed");
  28. try_again:
  29. while(1){
  30.     kp=0;
  31.     password =0;
  32.     while(!kp){kp = Keypad_Key_Press();}
  33.     switch (kp){
  34.           case  1: kp = 7; break; // 1        // Uncomment this block for keypad4x4
  35.           case  2: kp = 8; break; // 2
  36.           case  3: kp = 9; break; // 3
  37.  
  38.           case  5: kp = 4; break; // 4
  39.           case  6: kp = 5; break; // 5
  40.           case  7: kp = 6; break; // 6
  41.  
  42.           case  9: kp = 1; break; // 7
  43.           case 10: kp = 2; break; // 8
  44.           case 11: kp = 3; break; // 9
  45.           case 13:
  46.                goto omnia;
  47.           break;
  48.           case 14: kp = 48; break; // 0
  49.     }
  50.           password = password * 10 + kp;
  51.           }
  52.     omnia : if(password == 1234)
  53.             {
  54.                  PORTC.B2 = 1;
  55.                  LCD_Cmd(_LCD_CLEAR);
  56.                  LCD_Out_Cp("Openning...");
  57.             }
  58.             else
  59.             {
  60.                  PORTC.B2 = 0;
  61.                  LCD_Cmd(_LCD_CLEAR);
  62.                  LCD_out_cp("Emsek Haramy");
  63.                  goto try_again;
  64.             }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment