Lois
Published © CERN-OHL2

Simple Running Lights

A simple project suitable for beginners to get started with.

BeginnerProtip2 hours41

Things used in this project

Hardware components

5 mm LED: Yellow
5 mm LED: Yellow
×1
Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Online Simulation
PCBX Online Simulation

Hand tools and fabrication machines

Materia 101
Arduino Materia 101

Story

Read more

Schematics

Simple Running Lights

To implement this project, we need:

Some LEDs;
Resistors with appropriate resistance values to limit the current passing through the LEDs;
A switch to get the project running.

Code

Simple Running Lights

Arduino
Here, four yellow LEDs with a Forward Voltage of 2.4V and a Max Current of 0.03A are selected. To limit the current in the circuit to below 0.03A, the resistance value should be greater than 86Ω, hence R2 is set to 100Ω.

When the switch is closed, UNO detects a high level input on pin A0, and the running lights start to operate. If the switch is opened, no LEDs will be lit after the end of this cycle.
int led_pins[] = {2,3,4,5}, button_pin = A0;

void setup() {
    for (int i = 0; i < 4; i++) 
        pinMode(led_pins[i], OUTPUT);
    pinMode(button_pin, INPUT);
}

void loop() {
    if (digitalRead(button_pin) == HIGH)
        for (int i = 0; i < 4; i++) {
            digitalWrite(led_pins[i], HIGH);
            delay(250);
            digitalWrite(led_pins[i], LOW);
            delay(250);
        }
}

Credits

Lois
13 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.