uint8_t display7seg[16] = {0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B, 0x77, 0x1F, 0x4E, 0x3D, 0x4F, 0x47};
const byte coluna[4] = {0xF7, 0xFB, 0xFD, 0xFE};
void verificaBotao();
void setup() {
// put your setup code here, to run once:
// saída display
DDRD = 0xFF; //DDRx (1) saida (0) entrada
PORTD = ~0x7E; // se saída liga(1) ou desliga(0)
// entrada teclado
DDRB = 0x00; //DDRx (1) saida (0) entrada
PORTB = 0xFF; //habilita(1) pull-up if(se) entrada
// saída teclado
DDRC = 0xFF;
PORTC = 0xF7;
PORTD = ~display7seg[0];
}
void loop() {
PORTC = coluna[0];
// quando o botão 2 for pressionado
if ( (~PINC & (1<<3)) && (~PINB & (1<<3)) ) {
PORTD = ~display7seg[1];
} else if ( (~PINC & (1<<3)) && (~PINB & (1<<2)) ){
PORTD = ~display7seg[4];
} else if ( (~PINC & (1<<3)) && (~PINB & (1<<1)) ){
PORTD = ~display7seg[7];
} else if ( (~PINC & (1<<3)) && (~PINB & (1<<0)) ){
PORTD = ~display7seg[14];
}
PORTC = coluna[1];
if ( (~PINC & (1<<2)) && (~PINB & (1<<3)) ) {
PORTD = ~display7seg[2];
} else if ( (~PINC & (1<<2)) && (~PINB & (1<<2)) ){
PORTD = ~display7seg[5];
} else if ( (~PINC & (1<<2)) && (~PINB & (1<<1)) ){
PORTD = ~display7seg[8];
} else if ( (~PINC & (1<<2)) && (~PINB & (1<<0)) ){
PORTD = ~display7seg[0];
}
PORTC = coluna[2];
if ( (~PINC & (1<<1)) && (~PINB & (1<<3)) ) {
PORTD = ~display7seg[3];
} else if ( (~PINC & (1<<1)) && (~PINB & (1<<2)) ){
PORTD = ~display7seg[6];
} else if ( (~PINC & (1<<1)) && (~PINB & (1<<1)) ){
PORTD = ~display7seg[9];
} else if ( (~PINC & (1<<1)) && (~PINB & (1<<0)) ){
PORTD = ~display7seg[15];
}
PORTC = coluna[3];
if ( (~PINC & (1<<0)) && (~PINB & (1<<3)) ) {
PORTD = ~display7seg[10];
} else if ( (~PINC & (1<<0)) && (~PINB & (1<<2)) ){
PORTD = ~display7seg[11];
} else if ( (~PINC & (1<<0)) && (~PINB & (1<<1)) ){
PORTD = ~display7seg[12];
} else if ( (~PINC & (1<<0)) && (~PINB & (1<<0)) ){
PORTD = ~display7seg[13];
}
delay(300);
}