void setup() {
// put your setup code here, to run once:
volatile char *dir1;
dir1 = 0x30;
*dir1 = 0xff;
volatile char *dir2;
dir2 = 0x107;
*dir2 = 0xff;
volatile char *dir3; // rows port D
dir3 = 0x2A;
*dir3 = 0xff;
volatile char *dir4; //col port B
dir4 = 0x24;
*dir4 = 0x00;
}
void loop() {
// put your main code here, to run repeatedly:
volatile char *seg;
seg = 0x31;
volatile char *digit;
digit = 0x108;
volatile char *row; // rows port D
row = 0x2B;
volatile char *col; //col port B
col = 0x23;
*digit=0x08;
volatile char x,j,k;
volatile long i;
volatile int arr[]={0x10,0x20,0x40,0x80};
volatile int arr1[]={0xf9,0xa4,0xb0,0xf0};
volatile int arr2[]={0x99,0x92,0x82,0xf0};
volatile int arr3[]={0xf8,0x80,0x90,0xf0};
volatile int arr4[]={0x10,0xf9,0x54,0xf0};
*seg = 0xff;
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];}
}
}}
}