int led[] = {13, 12, 11, 10, 9, 8, 7}; // Variablen für die LEDs
int augen[6][7] = {
{0, 0, 0, 1, 0, 0, 0}, // Würfelzahl 1
{1, 0, 0, 0, 0, 0, 1}, // Würfelzahl 2
{1, 0, 0, 1, 0, 0, 1}, // Würfelzahl 3
{1, 0, 1, 0, 1, 0, 1}, // Würfelzahl 4
{1, 0, 1, 1, 1, 0, 1}, // Würfelzahl 5
{1, 1, 1, 0, 1, 1, 1} // Würfelzahl 6
};
int button = 4; // Variable für den Taster
int buttonStatus; // Statusabfrage des Tasters
void setup() {
for (int index = 0; index <= 6; index++) //
{ //
//
pinMode(led[index], OUTPUT); // LEDs als Ausgang definieren
//
} //
pinMode(button, INPUT); // Taster als Eingang // definieren
digitalWrite(button, HIGH); // Pull- Up- Widerstand // aktivieren
}
void loop() {
buttonStatus = digitalRead(button); // Status des Tasters abfragen
if (buttonStatus == LOW) // Wenn Taster gedrückt
{
for (int index1 = 0; index1 <= 50; index1++) // Liefer 51 Zufallszahlen
{
int zufall = random(0, 6); // Gib eine zufällige Zahl
// zwischen 1 und 6 an
randomSeed(analogRead(0)); // zufällige Zahl in zufälliger Reihenfolge
for (int index2 = 0; index2 <= 6; index2++)
{
digitalWrite(led[index2], augen[zufall][index2]);
}
delay(50); // 50ms verzögerung
}
}
}