#define inputPort 2
int portOutputs[] = {
7,
8,
9,
10,
11,
12,
13,
};
int lights[] = {
//_abcdefg
0b01111110, // 0
0b00110000, // 1
0b01101101, // 2
0b01111001, // 3
0b00110011, // 4
0b01011011, // 5
0b01011111, // 6
0b01110000, // 7
0b01111111, // 8
0b01111011 // 9
};
void setup() {
Serial.begin(115200);
pinMode(inputPort, INPUT);
for(int i = 0; i < 7; i++) {
pinMode(portOutputs[i], OUTPUT);
}
}
int counter = 0;
bool lastInputValue = LOW;
void loop() {
bool inputValue = digitalRead(inputPort);
if(inputValue == HIGH && lastInputValue == LOW) {
counter = (counter < 9) ? counter + 1 : 0;
}
lastInputValue = inputValue;
int lightsStates = lights[counter];
for(int i = 0; i < 7; i++) {
int targetPort = portOutputs[i];
int state = (lightsStates >> i) & 1;
digitalWrite(targetPort, state);
}
delay(15);
}