Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
BirdGuy
Published © GPL3+

Formula 1 Start Lights

Learn how to use a simple coding and LEDs to simulate a regulation start light sequence just like in Formula 1!

BeginnerShowcase (no instructions)2,855
Formula 1 Start Lights

Things used in this project

Hardware components

3 mm LED: Red
3 mm LED: Red
×5
Resistor 220 ohm
Resistor 220 ohm
×5
Resistor 10k ohm
Resistor 10k ohm
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Fritzing Diagram

Frizting Diagram

Code

Code

Arduino
int buttonState = 0;
long randNumber;

void setup() {
  randomSeed(analogRead(7));

{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, INPUT);
  }
}

void loop() {
  buttonState = digitalRead(7);
  randNumber = random(4000, 7000);

  if (buttonState == LOW) {

    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);   
  }

  else {

    digitalWrite(2, HIGH);
    delay(1000);
    digitalWrite(3, HIGH);
    delay(1000);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(5, HIGH);
    delay(1000);
    digitalWrite(6, HIGH);
    
    delay(randNumber);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
  }
  }

Credits

BirdGuy

BirdGuy

0 projects • 0 followers

Comments