#define satA P2_0
#define satB P2_1
#define satC P2_2
#define satD P2_3
#define sut1 P2_4
#define sut2 P2_5
#define sut3 P2_6
#define sut4 P2_7
char tus(void)
{
char don = ' ';
for (;;)
{
sut1=0;//1.sutunu kontrol et
while(!sut1)
{
while (satA==0) {while (satA==0) if(satA==1);don='1';}
while (satB==0) {while (satB==0) if(satB==1);don='4';}
while (satC==0) {while (satC==0) if(satC==1);don='7';}
while (satD==0) {while (satD==0) if(satD==1);don='C';}
sut1=1;
}
sut2=0;//2.sutunu kontrol et
while(!sut2)
{
while (satA==0) {while (satA==0) if(satA==1);don='2';}
while (satB==0) {while (satB==0) if(satB==1);don='5';}
while (satC==0) {while (satC==0) if(satC==1);don='8';}
while (satD==0) {while (satD==0) if(satD==1);don='0';}
sut2=1;
}
sut3=0;//3.sutunu kontrol et
while(!sut3)
{
while (satA==0) {while (satA==0) if(satA==1);don='3';}
while (satB==0) {while (satB==0) if(satB==1);don='6';}
while (satC==0) {while (satC==0) if(satC==1);don='9';}
while (satD==0) {while (satD==0) if(satD==1);don='=';}
sut3=1;
}
sut4=0;//4.sutunu kontrol et
while(!sut4)
{
while (satA==0) {while (satA==0) if(satA==1);don='/';}
while (satB==0) {while (satB==0) if(satB==1);don='*';}
while (satC==0) {while (satC==0) if(satC==1);don='-';}
while (satD==0) {while (satD==0) if(satD==1);don='+';}
sut4=1;
}
if(don != ' ') break;
}
return don;
}
here is a procedure to read from keypad. in C language.
satA...satD means the rows. and sut1...sut4 means columns.
Code:#define satA P2_0 #define satB P2_1 #define satC P2_2 #define satD P2_3 #define sut1 P2_4 #define sut2 P2_5 #define sut3 P2_6 #define sut4 P2_7 char tus(void) { char don = ' '; for (;;) { sut1=0;//1.sutunu kontrol et while(!sut1) { while (satA==0) {while (satA==0) if(satA==1);don='1';} while (satB==0) {while (satB==0) if(satB==1);don='4';} while (satC==0) {while (satC==0) if(satC==1);don='7';} while (satD==0) {while (satD==0) if(satD==1);don='C';} sut1=1; } sut2=0;//2.sutunu kontrol et while(!sut2) { while (satA==0) {while (satA==0) if(satA==1);don='2';} while (satB==0) {while (satB==0) if(satB==1);don='5';} while (satC==0) {while (satC==0) if(satC==1);don='8';} while (satD==0) {while (satD==0) if(satD==1);don='0';} sut2=1; } sut3=0;//3.sutunu kontrol et while(!sut3) { while (satA==0) {while (satA==0) if(satA==1);don='3';} while (satB==0) {while (satB==0) if(satB==1);don='6';} while (satC==0) {while (satC==0) if(satC==1);don='9';} while (satD==0) {while (satD==0) if(satD==1);don='=';} sut3=1; } sut4=0;//4.sutunu kontrol et while(!sut4) { while (satA==0) {while (satA==0) if(satA==1);don='/';} while (satB==0) {while (satB==0) if(satB==1);don='*';} while (satC==0) {while (satC==0) if(satC==1);don='-';} while (satD==0) {while (satD==0) if(satD==1);don='+';} sut4=1; } if(don != ' ') break; } return don; }
and here is the circuit for those codes.
**broken link removed**
thanks....i have again a question..how the scrolling be done?example i pressed 1 in the keypad and i have 4 seven segment the output would be 0001 and if i pressed 2 the output woould be 0012..
u searching for c codes ? i can give some codes but i dont use pic. i use 8051 so they are not same.
char cikis0 = 0x00, cikis1 = 0x00, cikis2 = 0x00, cikis3 = 0x00, giris;
int sayac = 0;
while(1)
{
giris = tus(); //using the function i gave. it will wait until u press a button.
sayac++
if(sayac<5)
{
cikis3 = cikis2;
cikis2 = cikis1;
cikis1 = cikis0;
cikis0 = giris;
}else
{
sayac = 0;
cikis0 = 0x00;
cikis1 = 0x00;
cikis2 = 0x00;
cikis3 = 0x00;
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?