void setup() {
// put your setup code here, to run once:
volatile char *dir1;
dir1 = 0x30; //directon reg for port f
*dir1 = 0xff; //port f as output
volatile char *dir2;
dir2 = 0x107; //direction reg for port k
*dir2 = 0x00; //port k as input
volatile char *dir3;
dir3 = 0x21; //direction reg for port a
*dir3 = 0xff; //port a as output
}
void loop() {
volatile char *row =(volatile char*) 0x31;
volatile char *col =(volatile char*)0x106;
volatile char *out =(volatile char*) 0x22;
volatile int arr[4][4]={{0x01,0x02,0x04,0x08},
{0x01,0x02,0x04,0x08},
{0x01,0x02,0x04,0x08},
{0x01,0x02,0x04,0x08},};
volatile int digit[4][4] = {{0x06,0x5b,0x4f,0x77},
{0x66,0x6d,0x7d,0x7f},
{0x07,0x7f,0x6f,0x39},
{0x49,0x3f,0x36,0x3f}};
volatile long i;
volatile int j,k,x;
for(j=0;j<4;j++)
{
*row = 1 << j;
if(*row != 0)
{
for(k=0;k<4;k++)
{
x = *col;
if(x == arr[j][k])*out = digit[j][k];
}
}
}
}