int led [5] = {0, 5, 4, 3, 2}; //Pin der LED
int buttonPin = 8; //Pin zum auslesen des Knopfs
int i = 0;
int j = 0;
int binary [4] = {0, 0, 0, 0};
void Umwandler(int dezimal, int binary[]) {
int index = 0;
while (dezimal > 0) {
binary[index] = dezimal % 2;
dezimal = dezimal / 2;
index++;
}
}
void setup() {
for (int j = 0; j < 4; ++j) {
pinMode(led[j + 1], OUTPUT);
}
pinMode(buttonPin, INPUT);
}
void loop() {
if (digitalRead(buttonPin) == HIGH) {
i++;
delay(50);
while (digitalRead(buttonPin) == HIGH) {
delay(150);
}
}
Umwandler(i, binary);
for (int j = 0; j < 4; ++j) {
digitalWrite(led[j + 1], binary[j] ? HIGH : LOW);
}
if (i > 15) {
i = 1;
}
}