Page 1 of 1

Password Door Security

PostPosted: Thu Jan 06, 2011 3:42 am
by shnidher
Hey all, i have a problem with my programme maded by mikroC
pic used here is PIC16F876A
basic issue here is comparing process
CODE: SELECT_ALL_CODE
-------------------------------------------------------------------
    int kp=0,oldkp=0,xx=0;
  char i=0,oldi=0;

// LCD module connections
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;

sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
char txt[5];                                // Declare an array to stall the 4-digit key in password
 char txt3[5]="1234";                // Declare an array to stall the 4-digit desired password

void main()
{   trisa=0;
   trisb=240;
  portb=0;
  Lcd_Init();                              // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);                     // Clear display
  Lcd_Cmd(_LCD_CURSOR_off);
   lcd_out(1,10,"Welcome");
  for(;;)
  {
   for(i=0; i<9; i++)
    {
     Lcd_Cmd(_LCD_SHIFT_RIGHT);
     delay_ms(100);
     }
       for(i=0; i<9; i++)
    {
     Lcd_Cmd(_LCD_SHIFT_LEFT);
     delay_ms(100);
     }
     portb=2;
     if(portb.f7==1) goto vv;
     }
     vv:
   Lcd_Cmd(_LCD_CLEAR);
  lcd_out(1,1,"prs1 entr code");
  lcd_out(2,1,"prs2 chng code");

   oo:

   do
   {
    ;
     portb=4;
   if(portb==132) kp=13;
    portb=8;
   if(portb==136) kp=12;
   }while(!kp);

    if(kp==12)
    {
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"entr code");
     goto said;
    }
    if(kp=13)
    {
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"chng code");
     goto said;
     }
     goto oo;
  said:
    do
    {
         portb=1;
     if(portb==17) kp=7;
     if(portb==33) kp=8;
     if(portb==65) kp=9;
     if(portb==129) kp=15;
      portb=2;
     if(portb==18) kp=4;
     if(portb==34) kp=5;
     if(portb==66) kp=6;
     if(portb==130) kp=14;
     portb=4;
     if(portb==20) kp=1;
     if(portb==36) kp=2;
     if(portb==68) kp=3;
     if(portb==132) kp=13;
     portb=8;
     if(portb==24) kp=0;
     if(portb==40) kp=10;
     if(portb==72) kp=11;
     if(portb==136) kp=12;
     }while(!kp);
       if(oldkp!=kp&&kp!=12&&kp!=13&&kp!=14&&kp!=15&&kp!=11)
     {
     txt[0]=kp%10+48;
     Lcd_Out(2, 4+xx,txt);
     xx++;
     delay_ms(500);
     if(xx==4) goto ff;
     } kp=0;
    goto said;
   ff:
     if((txt[0]==txt3[0])&&(txt[1]==txt3[1]))

   {
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Out(1,1,"ok!");
   while(1);   
                         }
    else
{
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(2,1,"ERROR!");
    while(1);
                          }
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------

any suggestions as soon as any one can, thx all ^_^

Re: Password Door Security

PostPosted: Thu Jan 06, 2011 7:20 am
by ABSF
Since you didnt attach the schematics, are you implying that the LCD and keypad HW parts are OK? Did you test the indivisual SW functions and confirmed that they are working without problem?


Just my 3 cents.

Allen

Re: Password Door Security

PostPosted: Thu Jan 06, 2011 2:02 pm
by ober
which part of code is having problem? I am not familiar with MikroC, it will be great if you can point out particular part of your code having problem and forumer can focus at the portion of code to give suggestion.

Also what is the result you getting now? LCD working? Is there message?

Re: Password Door Security

PostPosted: Mon Jan 17, 2011 4:57 am
by shnidher
hey sorry all for not replaying , ok i found the problem in my formula, any one need to see my work just tell me a,d i will show it fo you, thx again good luck ^_*

Re: Password Door Security

PostPosted: Mon Jan 17, 2011 8:05 am
by shiyan
shnidher WROTE:hey sorry all for not replaying , ok i found the problem in my formula, any one need to see my work just tell me a,d i will show it fo you, thx again good luck ^_*


Woh! Everyone would like to see it, share it here, paste some photos, explain a bit. :D

Re: Password Door Security

PostPosted: Sun Feb 13, 2011 8:30 pm
by shnidher
Hello all, by those next days my work will be in your hands, it's just need a little final tutches