#define INCREASE_BUTTON_PIN 8
const int numbers[10] = {
0x40,
0x79,
0x24,
0x30,
0x19,
0x12,
0x02,
0x78,
0x00,
0x10
};
void setup() {
DDRD = 0xFF;
PORTD = 0xFF;
DDRC = 0x0F;
PORTC = 0x0F;
pinMode(INCREASE_BUTTON_PIN, INPUT);
}
int currentPort = 1;
int dig4counter = 0;
int dig3counter = 0;
int dig2counter = 0;
int dig1counter = 0;
void loop() {
PORTC = 1;
setDigit(1, dig1counter);
PORTC = 2;
setDigit(2, dig2counter);
PORTC = 4;
setDigit(4, dig3counter);
PORTC = 8;
setDigit(8, dig4counter);
int increasePin = digitalRead(INCREASE_BUTTON_PIN);
if (increasePin){
if (dig2counter == 9 && dig3counter == 9 && dig4counter == 9){
dig1counter = (dig1counter + 1 ) % 10;
}
if (dig3counter == 9 && dig4counter == 9){
dig2counter = (dig2counter + 1 ) % 10;
}
if (dig4counter == 9){
dig3counter = (dig3counter + 1 ) % 10;
}
dig4counter = (dig4counter + 1 ) % 10;
delay(100);
}
}
void setDigit(int index, int digit){
PORTD = 0xFF; //reset with HIGH
PORTD = numbers[digit];
PORTD = 0xFF; //reset with HIGH
}