uint8_t display7seg[16] = {0x7E,
0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F,
0x70, 0x7F, 0x7B, 0x77, 0x1F, 0x4E, 0x3D, 0x4F, 0x47};
uint8_t coluna[4] = {0xF7, 0xFB, 0xFD, 0xFE};
void setup() {
// put your setup code here, to run once:
// put your setup code here, to run once:
// saída display
DDRD = 0xFF; //DDRx (1) saida (0) entrada
PORTD = ~display7seg[0];
// configurar saida teclado
DDRC = 0xFF;
PORTC = 0b11110111;
// configurar entrada teclado
DDRB = 0x00;
PORTB = 0xFF;
}
void loop() {
// put your main code here, to run repeatedly:
// coluna 1
PORTC = coluna[0]; // F7
if (~PINB & 1<<3){
PORTD = ~display7seg[1];
} else if (~PINB & 1<<2){
PORTD = ~display7seg[4];
} else if (~PINB & 1<<1){
PORTD = ~display7seg[7];
} else if (~PINB & 1<<0){
PORTD = ~display7seg[14];
}
// coluna 2
PORTC = coluna[1]; //FB
if (~PINB & 1<<3){
PORTD = ~display7seg[2];
} else if (~PINB & 1<<2){
PORTD = ~display7seg[5];
} else if (~PINB & 1<<1){
PORTD = ~display7seg[8];
} else if (~PINB & 1<<0){
PORTD = ~display7seg[0];
}
// coluna 3
PORTC = coluna[2]; //FD
if (~PINB & 1<<3){
PORTD = ~display7seg[3];
} else if (~PINB & 1<<2){
PORTD = ~display7seg[6];
} else if (~PINB & 1<<1){
PORTD = ~display7seg[9];
} else if (~PINB & 1<<0){
PORTD = ~display7seg[15];
}
// coluna 4
PORTC = coluna[3]; //FE
if (~PINB & 1<<3){
PORTD = ~display7seg[10];
} else if (~PINB & 1<<2){
PORTD = ~display7seg[11];
} else if (~PINB & 1<<1){
PORTD = ~display7seg[12];
} else if (~PINB & 1<<0){
PORTD = ~display7seg[13];
}
}