const int switchPin=2;
const int counterPins[]={5,18,23,22,21,17,19};
int counter=0;
int switchState=HIGH;
int lastSwitchState=HIGH;
void setup()
{pinMode(switchPin,INPUT_PULLUP);
for(int i=0;i<7;i++){
pinMode(counterPins[i],OUTPUT);
}
displayDigit(counter);
}
void displayDigit(int digit){
int data[10][7]={
{0,0,0,0,0,0,1},
{1,0,0,1,1,1,1},
{0,0,1,0,0,1,0},
{0,0,0,0,1,1,0},
{1,0,0,1,1,0,0},
{0,1,0,0,1,0,0},
{0,1,0,0,0,0,0},
{0,0,0,1,1,1,1},
{0,0,0,0,0,0,0},
{0,0,0,0,1,0,0}
};
for(int i=0;i<7;i++){
digitalWrite(counterPins[i],data[digit][i]);
}
}
void loop(){
switchState=digitalRead(switchPin);
if(switchState==LOW&&lastSwitchState==HIGH){
counter=(counter+1)%10;
displayDigit(counter);
delay(1000);
}
lastSwitchState=switchState;
}