void setup() {
// put your setup code here, to run once:
volatile char *PORT_F_DIR_REG = (char*) 0x30;
*PORT_F_DIR_REG = 0xFF;
volatile char *PORT_K_DIR_REG = (char*) 0x107;
*PORT_K_DIR_REG = 0xFF;
volatile char *PORT_A_DIR_REG = (char*) 0x21;
*PORT_A_DIR_REG = 0x00;
}
void loop() {
// put your main code here, to run repeatedly:
volatile char combinations[16] = {
0x11,
0x21,
0x41,
0x81,
0x12,
0x22,
0x42,
0x82,
0x14,
0x24,
0x44,
0x84,
0x18,
0x28,
0x48,
0x88
};
volatile char sevseg[16] = {
0x06,
0x5B,
0x4F,
0x77,
0x66,
0x6D,
0x7D,
0x7C,
0x07,
0x7F,
0x6F,
0x39,
0x79,
0x3F,
0x79,
0x5E
};
volatile char *PORT_F_DATA_REG = (char*) 0x31;
volatile char *PORT_K_DATA_REG = (char*) 0x108;
volatile long i,j,k;
volatile char *PORT_A_INPUT_REG = (char*) 0x20;
volatile char input_data;
for (i = 0; i < 4; i++){
*PORT_F_DATA_REG = (1 << i);
input_data = *PORT_A_INPUT_REG;
if (input_data !=0) {
input_data |= *PORT_F_DATA_REG;
for(j = 0; j<16; j++) {
if((input_data & combinations[j]) == combinations[j]){
*PORT_K_DATA_REG = sevseg[j];
for(k = 0; k < 20000; k++);
}
}
}
}
}