// Set three variables for the three LED pins
int redPin = 13;
int greenPin = 12;
int bluePin = 11;
// In the setup fucntion, set all LED pins to output
void setup() {
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// Create an array with the LED pins
int pinsToUse[] = {redPin, greenPin, bluePin};
// Create an array with three positions that is randomly
// either 0 (the LED is off) or 1 (the LED is on)
int ledsOnOrder[] = {random(2), random(2), random(2)};
// Use a for loop to set the LEDs on or off
for (int i = 0; i <= 2; i++) {
// Use digitalWrite to set the LEDs to on or off
digitalWrite(pinsToUse[i], ledsOnOrder[i]);
}
// Wait for half a second
delay(500);
}