// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // *********/ // Pin connected to the LED const int ledPins[] = {2, 5, 11, 12, 15}; // Time interval between actions (in milliseconds) const int actionInterval = 50; // 1 second void setup() { // Set pins 0 to 15 as OUTPUT and set them to LOW const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; for (int i = 0; i < sizeof(ledPins) / sizeof(ledPins[0]); i++) { pinMode(ledPins[i], OUTPUT); digitalWrite(ledPins[i], HIGH); } randomSeed(analogRead(0)); // Seed the random number generator } void toggleRandomLED() { // Select a random LED pin int randomIndex = random(0, sizeof(ledPins) / sizeof(ledPins[0])); // Toggle the selected LED state digitalWrite(ledPins[randomIndex], !digitalRead(ledPins[randomIndex])); } void loop() { // Toggle a random LED every actionInterval milliseconds toggleRandomLED(); delay(actionInterval); }