#define LED_1 0 #define LED_2 1 #define LED_3 2 #define LED_4 3 #define LED_5 4 #define LED_6 5 #define LED_7 6 #define LED_8 7 #define LED_SWITCH 8 int LEDs[]={LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8}; int dice[6][8]={ {0, 0, 1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 0}, {0, 1, 1, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 1, 1, 0, 1}, {0, 1, 1, 0, 1, 1, 0, 1}, {0, 1, 0, 1, 1, 1, 1, 1} }; // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_SWITCH, OUTPUT); for(int i = 0; i < 8; i++){ pinMode(LEDs[i], OUTPUT); } } // the loop function runs over and over again forever void loop() { // LED dice digitalWrite(LED_SWITCH, LOW); //for(int j = 0; j < 6; j++){ int j = random(0,6); for(int i = 0; i < 8; i++){ if (dice[j][i] == 1) digitalWrite(LEDs[i], HIGH); else{ digitalWrite(LEDs[i], LOW); } } delay(random(1,6)*100); PORTD = 0b00000000; delay(500); //} PORTD = 0b00000000; }