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() {
// put your main code here, to run repeatedly:
volatile int i,x,j,k;
volatile char *row;
row = 0x31;
volatile char *col;
col = 0x106;
volatile char *seg;
seg = 0x22;
volatile int arr[]={0x01,0x02,0x04,0x08};
volatile int arr1[]={0x06,0x5b,0x4f,0x01};
volatile int arr2[]={0x66,0x6d,0x7d,0x02};
volatile int arr3[]={0x07,0x7f,0x6f,0x03};
volatile int arr4[]={0x01,0x3f,0x42,0x03};
x = *col;
while(1){
for(k=0;k<4;k++)
{
*row = 1 << k;
if (*row == 1)
{for(j=0;j<4;j++)
{
x = *col;
if((x & arr[j]) == arr[j]) *seg = arr1[j];
}}
if (*row == 2)
for(j=0;j<4;j++)
{
x = *col;
if((x & arr[j]) == arr[j]) *seg = arr2[j];
}
if (*row == 4)
for(j=0;j<4;j++)
{
x = *col;
if((x & arr[j]) == arr[j]) *seg = arr3[j];
}
if (*row == 8)
for(j=0;j<4;j++)
{
x = *col;
if((x & arr[j]) == arr[j]) *seg = arr4[j];
}
}}
}