#define TEMPO 100
void printDisplay(uint16_t numero);
uint8_t display7seg[16] = {0x7E,
0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F,
0x70, 0x7F, 0x7B, 0x77, 0x1F, 0x4E, 0x3D, 0x4F, 0x47};
uint16_t contador = 9999;
void setup() {
// put your setup code here, to run once:
DDRD = 0xFF;
PORTD = ~display7seg[0];
DDRB = 0xFF;
PORTB = 0x0F;
}
void loop() {
printDisplay(1987);
delay(TEMPO);
}
void printDisplay(uint16_t numero){
uint16_t resto = 0;
uint16_t listaNumero[4] = {0,0,0,0};
uint16_t contador = 0;
while(numero !=0){
resto = numero % 10;
numero = numero / 10;
listaNumero[contador++] = resto;
}
// put your main code here, to run repeatedly:
PORTD = ~display7seg[listaNumero[0]];
PORTB = 0x01;
delay(1);
PORTB = 0x00;
PORTD = ~display7seg[listaNumero[1]];
PORTB = 0x01<<1;
delay(1);
PORTB = 0x00;
PORTD = ~display7seg[listaNumero[2]];
PORTB = 0x01<<2;
delay(1);
PORTB = 0x00;
PORTD = ~display7seg[listaNumero[3]];
PORTB = 0x01<<3;
delay(1);
PORTB = 0x00;
}