0% found this document useful (0 votes)
5 views2 pages

Document 3: Arduino Mini Projects: LED Randomizer Arduino Mini Projects: LED Randomizer Introduc On

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Document 3: Arduino Mini Projects: LED Randomizer Arduino Mini Projects: LED Randomizer Introduc On

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Document 3: Arduino Mini Projects: LED Randomizer

Arduino Mini Projects: LED Randomizer

Introduc on:
This Arduino project demonstrates how to use randomness and control mul ple LEDs. It’s ideal for beginners
looking to explore coding and basic circuits.

Project Components:

 Arduino Uno or any compa ble board

 5 LEDs and 5 resistors (220 ohms)

 Breadboard and jumper wires

 Push bu on

Circuit Setup:

1. Connect each LED to a digital pin (e.g., D2 to D6).

2. Place resistors between LEDs and ground.

3. Connect the bu on to an input pin with a pull-down resistor.

The Code:
The program uses the random() func on to light up 1–5 LEDs:

cpp

Copy code

int ledPins[] = {2, 3, 4, 5, 6};

int bu onPin = 7;

void setup() {

for (int i = 0; i < 5; i++) {

pinMode(ledPins[i], OUTPUT);

pinMode(bu onPin, INPUT);

void loop() {

if (digitalRead(bu onPin) == HIGH) {

int randomLEDs = random(1, 6); // 1 to 5

for (int i = 0; i < randomLEDs; i++) {

digitalWrite(ledPins[i], HIGH);

delay(500);

digitalWrite(ledPins[i], LOW);

}
}

Tips for Beginners:

 Double-check connec ons to avoid short circuits.

 Experiment by changing the delay or LED pa erns.

Conclusion:
This project introduces randomness and basic coding, providing a founda on for advanced projects like games or
sensors.

You might also like