//ESP - keypad - problems set1
//Use 4 x 4 Keypad and Quard 7 segment display
// 01-Press any switch & display that number // 11 - 11 - 2022
void setup() {
// put your setup code here, to run once:
volatile char *dirf,*dirk,*dira,*dirc;
volatile char *outf,*outa,*outc;
volatile char *ink;
volatile long i,j,x;
volatile char numca[]={0xC0,0xF9,0xA4,0xB0,0X99,0X92,0X82,0xF8,0x80,0x98};
dirf = 0x30; dirk = 0x107; dira = 0x21; dirc = 0x27;
*dirf = 0x0f; *dirk = 0x00; *dira = 0xff; *dirf = 0x0f;
outa = 0x22; outf = 0x31; outc = 0x28;
ink = 0x106;
while(1)
{
for(i=0;i<4;i++)
{
*outf=1 << i;
x=*ink;
if(*outf==1 && x == 1)
{
*outc=0x0f;
*outa=numca[1];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==1 && x == 2)
{
*outc=0x0f;
*outa=numca[2];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==1 && x == 4)
{
*outc=0x0f;
*outa=numca[3];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==2 && x == 1)
{
*outc=0x0f;
*outa=numca[4];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==2 && x == 2)
{
*outc=0x0f;
*outa=numca[5];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==2 && x == 4)
{
*outc=0x0f;
*outa=numca[6];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==4 && x == 1)
{
*outc=0x0f;
*outa=numca[7];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==4 && x == 2)
{
*outc=0x0f;
*outa=numca[8];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==4 && x == 4)
{
*outc=0x0f;
*outa=numca[9];
for(j=0;j<500000;j++);
*outc=0x00;
}
if(*outf==8 && x == 2)
{
*outc=0x0f;
*outa=numca[0];
for(j=0;j<500000;j++);
*outc=0x00;
}
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}