Code:
// Lcd pinout settings
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_d7 at RD7_bit;
unsigned short cnt ;
// Pin direction
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_d7_Direction at TRISD7_bit;
char keypadPort at PORTB;
int i;
char password1[8];
char passworda()
{
line1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Enter Password :");
for(i=0;i<7;i++)
{
while (password1[i] == 0)
{
password1[i] = Keypad_Key_click(void);
}
if(password1[i]==1) password1[i] = '1';
if(password1[i]==2) password1[i] = '2';
if(password1[i]==3) password1[i] = '3';
if(password1[i]==5) password1[i] = '4';
if(password1[i]==6) password1[i] = '5';
if(password1[i]==7) password1[i] = '6';
if(password1[i]==9) password1[i] = '7';
if(password1[i]==10) password1[i] = '8';
if(password1[i]==11) password1[i] = '9';
if(password1[i]==13) password1[i] = '*';
if(password1[i]==14) password1[i] = '0';
if(password1[i]==15) password1[i] = '#';
Lcd_Chr(2, i+1 ,password1[i] );
}
if(strcmp(password1,"#123456") == 0) {return 1;}
{
goto line1;
}
}
int main ()
{
trisc=0; portc=0;
Lcd_Init(); keypad_Init(); // password1
Lcd_Cmd(_LCD_CURSOR_OFF);
passworda ();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,4 , "zakljucano");
}
// Lcd pinout settings
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_d7 at RD7_bit;
unsigned short cnt ;
// Pin direction
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_d7_Direction at TRISD7_bit;
char keypadPort at PORTB;
int i;
char password1[8];
char passworda()
{
line1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Enter Password :");
for(i=0;i<7;i++)
{
while (password1[i] == 0)
{
password1[i] = Keypad_Key_click(void);
}
if(password1[i]==1) password1[i] = '1';
if(password1[i]==2) password1[i] = '2';
if(password1[i]==3) password1[i] = '3';
if(password1[i]==5) password1[i] = '4';
if(password1[i]==6) password1[i] = '5';
if(password1[i]==7) password1[i] = '6';
if(password1[i]==9) password1[i] = '7';
if(password1[i]==10) password1[i] = '8';
if(password1[i]==11) password1[i] = '9';
if(password1[i]==13) password1[i] = '*';
if(password1[i]==14) password1[i] = '0';
if(password1[i]==15) password1[i] = '#';
Lcd_Chr(2, i+1 ,password1[i] );
}
if(strcmp(password1,"#123456") == 0) {return 1;}
{
goto line1;
}
}
int main ()
{
trisc=0; portc=0;
Lcd_Init(); keypad_Init(); // password1
Lcd_Cmd(_LCD_CURSOR_OFF);
passworda ();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,4 , "zakljucano");
}
[Ovu poruku je menjao X Files dana 08.08.2014. u 19:43 GMT+1]