// int CommonAnode[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
// int currentDigit = 0;
// void setup() {
// DDRD = 0xFF;
// pinMode(10, INPUT_PULLUP);
// }
// void loop() {
// if (digitalRead(10) == LOW) {
// currentDigit = (currentDigit + 1) % 10;
// displayDigit(currentDigit);
// delay(500);
// }
// }
// void displayDigit(int digit) {
// PORTD = CommonAnode[digit];
// }
// int switchPin = 10;
// int switchState = HIGH;
// int prevSwitchState = HIGH;
// int pressCount = 0;
// void setup() {
// pinMode(switchPin, INPUT_PULLUP);
// Serial.begin(9600);
// }
// void loop() {
// switchState = digitalRead(switchPin);
// if (switchState == LOW) {
// pressCount++;
// Serial.print("Switch Press Count: ");
// Serial.println(pressCount);
// }
// prevSwitchState = switchState;
// }
//Counter using SSD and Push button
int CommonAnode[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
int count=0;
int s =0;
void setup() {
pinMode(10, INPUT_PULLUP);
DDRD=B11111111;
}
void loop() {
int x = digitalRead(10);
if (x == HIGH && s == 0) {
PORTD=CommonAnode[count];
count++;
s = 1;
if (count>9){
count=0;
}
}
else if(x==LOW) {
s = 0;
}
delay(100);
}