zakir_cool
Junior Member level 3
- Joined
- Sep 27, 2012
- Messages
- 31
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,558
Hi i am trying keypad interfacing using PIC16F877a,this code is giving a error,but this same is code working fine in 8051 with little modification of ports.Can any body figure it out what's the mistake.my intention is to give four char password.
unsigned char pass[4];
#define c1 RA5;
#define c2 RA6;
#define c3 RA7;
#define r1 RA0;
#define r2 RA1;
#define r3 RA2;
void keypad()
{
unsigned int i;
i=0;
do
{
r1=0; r2=r3=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='1';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='2';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='3';
lcddata('*');
}
r2=0; r1=r3=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='4';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='5';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='6';
lcddata('*');
}
r3=0; r2=r1=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='7';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='8';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='9';
}
}while(i<=3);
pass='\0';
}
Code:
#define c1 RA5;
#define c2 RA6;
#define c3 RA7;
#define r1 RA0;
#define r2 RA1;
#define r3 RA2;
void keypad()
{
unsigned int i;
i=0;
do
{
r1=0; r2=r3=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='1';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='2';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='3';
lcddata('*');
}
r2=0; r1=r3=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='4';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='5';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='6';
lcddata('*');
}
r3=0; r2=r1=1;
if(c1==0)
{
while(c1==0);
delay(5000);
pass[i++]='7';
lcddata('*');
}
if(c2==0)
{
while(c2==0);
delay(5000);
pass[i++]='8';
lcddata('*');
}
if(c3==0)
{
while(c3==0);
delay(5000);
pass[i++]='9';
}
}while(i<=3);
pass='\0';
}