Loading...
Loading...
// Random Building Lights
const int NUM_LIGHTS = 8;
const int lightPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
void setup() {
for (int i = 0; i < NUM_LIGHTS; i++) {
pinMode(lightPins[i], OUTPUT);
}
randomSeed(analogRead(0));
}
void loop() {
int light = random(NUM_LIGHTS);
digitalWrite(lightPins[light], !digitalRead(lightPins[light]));
delay(random(2000, 10000)); // 2-10 second intervals
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.