Light Show

Ever start listening to a bomb ass song and wish you could have some sick lights to correspond to the music? Me too!

I’ve created a board that you can press several switches and alternate the light patterns. They range from fast to slow and various other combinations. Right now there are only 4 light combinations but with enough funding there’s sure to be more!… Anyways, here’s a video of me jamming out to the song Hey Daddy by Usher #tbt amirite

Here’s a diagram for your viewing pleasure:

Light Show_bb

As well as a picture:

2015-09-13 23.57.53

Pretty straight forward stuff in terms of hardware. Orange wires are for output, Blue wires are for input, Red wires for power, and Black for ground. I attached the 110 resistors so I pull the charge away from the switch for stability. I used the 330 resistors for the LEDs so they don’t blow. I hooked up the Blue switch to input 4, Red switch to input 5, and Green switch to input 6. The outputs are 3, 8, and 9 for the Blue, Yellow, and Red LEDs respectively. However, the hardware doesn’t implement the light show combinations.

The magic happens in the software:

void setup() {
  // put your setup code here, to run once:
  pinMode(3, OUTPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
    if(digitalRead(4) == HIGH && digitalRead(6) == HIGH && digitalRead(5) == LOW){
      digitalWrite(8, LOW);
      digitalWrite(3, HIGH);
      digitalWrite(9, HIGH);
      delay(500);
      digitalWrite(8, HIGH);
      digitalWrite(3, LOW);
      digitalWrite(9, LOW);
      delay(500);
      digitalWrite(8, LOW);
  }
  else if(digitalRead(4) == HIGH){
    digitalWrite(3,HIGH);
     delay(12);
     digitalWrite(3,LOW);
     delay(12);
     digitalWrite(8,HIGH);
     delay(25);
     digitalWrite(8,LOW);
     delay(25);
     digitalWrite(9,HIGH);
     delay(50);
     digitalWrite(9,LOW);
     delay(50);
  }
  else if(digitalRead(5) == HIGH){
     digitalWrite(3,HIGH);
     delay(25);
     digitalWrite(3,LOW);
     delay(25);
     digitalWrite(8,HIGH);
     delay(50);
     digitalWrite(8,LOW);
     delay(50);
     digitalWrite(9,HIGH);
     delay(100);
     digitalWrite(9,LOW);
     delay(100);
  }
  else if(digitalRead(6) == HIGH){
     digitalWrite(3,HIGH);
     delay(50);
     digitalWrite(3,LOW);
     delay(50);
     digitalWrite(8,HIGH);
     delay(100);
     digitalWrite(8,LOW);
     delay(100);
     digitalWrite(9,HIGH);
     delay(200);
     digitalWrite(9,LOW);
     delay(200);
  }
}

Viola! The four combinations I mentioned are basically:

Blue:  Fast sequential blinking of the blue LED, then yellow, then red.

Red: Slightly slower than the blue button

Green: Even slower than Red button

Blue + Green: Blue and Red blink at the same time while Yellow LED is off, then after 500ms they alternate resulting in the Blue and Red LEDs being off and the Yellow one being on

 

I did run into several problems. Initially, I tried to make a combination lock but failed horribly. Then I thought of this. A few problems I faced were the lights would stay on even though I let go of the switch. The resistors seemed to do the job of pulling the current away from the switch most of the time, but in a few cases it gets inconsistent.

 

 

Leave a Reply