Project tutorial
The Light Box

The Light Box © GPL3+

This infinity mirror with individual programmable LEDs loops through 20 light effects, guards your room in the dark and plays a memory game.

  • 4,234 views
  • 2 comments
  • 20 respects

Components and supplies

One Way Mirror 135 x 135 mm Acrylic
×1
Two Way Mirror 135 x 135 mm Acrylic
×1
Aluminum Lath 465 mm x 30 mm x 2 mm
×1
Addressable RGB strip WS2812 LEDs
1 strip of 21 LEDs, 2 strips of 27 LEDS
×3
Ard nano
Arduino Nano R3
×1
Power Supply 5V
×1
398 09
Adafruit RGB Backlight LCD - 16x2
×1
SPDT Switch
×1
Adafruit industries ada161 image 75px
Photo resistor
×1
Trimpotentiometer 10K
×2
IR receiver + remote
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×4
Mfr 25frf52 1k sml
Resistor 1k ohm
×1
08377 02 l
Resistor 330 ohm
×5
Mfr 25fbf52 221r sml
Resistor 221 ohm
×4
Fairchild semiconductor 1n4004. image
1N4007 – High Voltage, High Current Rated Diode
×1
09590 01
LED (generic)
×2
Panasonic eca2am101
Capacitor 100 µF
×1
DC Socket 5,5x2,1
×1
PMMA Acrylic approx. 400 x 200 x 3 mm
×1
Acrifix1S0117
×1

Apps and online services

Ide web
Arduino IDE
Fritzing.org
http://www.bensound.com
Music for video

About this project

Code

The_LIGHT_BOX.inoArduino
#include "FastLED.h"                                              //Include leds library

CRGBPalette16 currentPalette;                                     //FastLED.h settings      
TBlendType    currentBlending;
uint8_t startIndex = 1;
uint8_t gHue = 0;

int num_leds[3]={21,27,27};                                       //# of leds per strip,Outer strip, Inner strip1,Inner strip2

#define DATA_PIN0 15                                              //Define DATA_PIN that will manage each ledstrip 
#define DATA_PIN1 16
#define DATA_PIN2 17

                                                                  //Define the array of leds
CRGB leds[3][27];                                                 //LEDS[0] = outer strip
                                                                  //LEDS[1] = inner/front strip
                                                                  //LEDS[2] = inner/back strip

#include <IRremote.h>                                             //Include IR library
IRrecv myreceiver(18);                                            //Receiver-object called 'myreceiver'on pin18
decode_results myinput;                                           //Variable of type decode_results 'myinput'
int previousCode =0;                                              //Initiating code from IR sender
int lastIRcode = 0;         

#include <LiquidCrystal.h>                                        //Include library LCD screen
const int rs = 13, en = 12, d4 = 8, d5 = 7, d6 = 4, d7 = 2;       //Initialize LCD interface pin with the arduino pin numbers
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int musicPin=19;                                                  //Set up music
char songPlayMemory1[]="cfcfcfcfgfefg ";                          //GameMelodie
int beatsPlayMemory1[]={2,4,2,4,2,8,2,2,1,2,4,2,10,4};
int tempoPlayMemory1=190;

int command = 0;                                                  //Programvariables
int cycles=0;
int repeatlight=0;
int howlong = 0;
boolean wrong = false;
//----------------------------------LIGHT FUNCTIONS-------------------------------------------------------------------------
void rainbow() {                                                  //FastLED's built-in rainbow generator 
  fill_rainbow( leds[2], num_leds[2], gHue, 7);
  fill_rainbow( leds[0], num_leds[0], gHue, 7);
}

void addGlitter( fract8 chanceOfGlitter) {
  if( random8() < chanceOfGlitter) {
    leds[2][ random16(num_leds[2]) ] += CRGB::White;
    leds[0][ random16(num_leds[0]) ] += CRGB::White;
  }
}

void rainbowWithGlitter() {                                       //Built-in FastLED rainbow, plus some random sparkly glitter  
  rainbow();
  addGlitter(80);
}

void confetti() {                                                 //Random colored speckles that blink in and fade smoothly
  fadeToBlackBy(leds[2], num_leds[2], 10);
  int pos = random16(num_leds[2]);
  leds[2][pos] += CHSV( gHue + random8(64), 200, 255);
  fadeToBlackBy(leds[0], num_leds[0], 10);
  int pos2 = random16(num_leds[0]);
  leds[0][pos2] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon(int less, uint8_t color, int cona) {                 //A colored dot sweeping back and forth, with fading trails
  fadeToBlackBy(leds[2], num_leds[2]-less, 20);
  int pos = beatsin16( cona, 0, num_leds[2]-1-less );
  leds[2][pos] += CHSV( color, 255, 192);
  fadeToBlackBy(leds[0], 21, 20);
  int pos2 = beatsin16( cona, 0, 20 );
  leds[0][pos2] += CHSV( color, 255, 192);
}

void bpm() {                                                      //Colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < num_leds[2]; i++) { 
    leds[2][i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
  for( int i = 0; i < num_leds[0]; i++) { 
    leds[0][i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}


void juggle() {                                                   //Eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds[2], num_leds[2], 20);
  fadeToBlackBy( leds[0], num_leds[0], 20);
  byte dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[2][beatsin16( i+7, 0, num_leds[2]-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
  dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[0][beatsin16( i+7, 0, num_leds[0]-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

void allSameColor(int s,int R,int G, int B){
    fill_solid(leds[s], num_leds[s], CRGB(R,G,B));
    FastLED.show();
  }

void flash2strips(){
  for(int s=1;s<3;s++){
  allSameColor(s,255,255,0);
  FastLED.show();
  delay(250);
  allSameColor(s,0,0,0);  
  FastLED.show();
  delay(100);
  }   
}

void FillLEDsFromPaletteColors0(uint8_t colorIndex){
    uint8_t brightness = 255;
    
    for( int i = 0; i < num_leds[0]; i++) {
        leds[0][i] = ColorFromPalette(currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }
}

void FillLEDsFromPaletteColors(uint8_t colorIndex, int which){
    uint8_t brightness = 255;
    int incr=1;
    if(which == 2){incr = 2;}
    for(int i = 0; i < num_leds[1]; i=i+incr) {
        leds[1][i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);       
        if(which == 2){leds[2][i+1] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);}    
        colorIndex += 3;
       }
        if(which == 3){for( int i = 0; i < num_leds[1]; i=i+2) {
        leds[2][i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;} 
        }    
}

void SetupTotallyRandomPalette(){
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

void SetupBlackAndWhiteStripedPalette(){
    fill_solid( currentPalette, 16, CRGB(0,0,0));
    currentPalette[0] = CRGB(255,255,255);
    currentPalette[4] = CRGB(255,255,255);
    currentPalette[8] = CRGB(255,255,255);
    currentPalette[12] = CRGB(255,255,255);    
}

void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;    
    currentPalette = CRGBPalette16(
      green,  green,  black,  black,
      purple, purple, black,  black,
      green,  green,  black,  black,
      purple, purple, black,  black );
}

void randomhits(){
    for(int a=0;a<180;a++){
    leds[0][ random16(num_leds[0]) ] += CRGB::White;
    if(a%2==0){leds[1][ random16(num_leds[1]) ] += CRGB::White;
    }else{
      leds[2][ random16(num_leds[2]) ] += CRGB::White;}   
    FastLED.show();
    for(int s=0;s<3;s++){
      fill_solid( leds[s], num_leds[s], CRGB(0,0,0));
      }
    FastLED.show();
    } 
}

void lightning(){
    randomSeed(analogRead(0));
    int rnd1 = random(0,26);
    int rnd2 = random(1,6);
      for(int i=0;i<rnd2;i++){
      leds[1][rnd1] = CRGB(255,255,255);
      FastLED.show();
      delay(random(0,40)); 
      leds[1][rnd1] = CRGB(0,0,0);
      FastLED.show();
      }
      delay(random(10,600));   
    }
//----------------------------------LCD FUNCTIONS---------------------------------------------------------------------------
void lcdProgramMessage(){
  lcd.setCursor(0, 0);
  lcd.print("                ");
  lcd.setCursor(13, 0);
  lcd.print("#");
  lcd.print(command-3);
  lcd.setCursor(0, 1);
  lcd.print("                ");
}

void lcdTitles(String title){
  lcd.setCursor(0,1);                    
  lcd.print(title);
  for(int s=0;s<3;s++){
  allSameColor(s,0,0,0);
  }
}    
//----------------------------------MUSIC FUNCTIONS-------------------------------------------------------------------------
void playTone(int tone, int duration){
  for (long i=0;i<duration*250L;i+=tone*2){
    digitalWrite(musicPin,HIGH);
    delayMicroseconds(tone);
    digitalWrite(musicPin,LOW);
    delayMicroseconds(tone);
  }
}

void playNote(char note, int duration){
  char names[]={'c','d','e','f','g','a','b','C'};
  int tones[]={1915,1700,1519,1432,1275,1136,1014,956};
  for(int i=0;i<8;i++){
    if(names[i]==note){playTone(tones[i],duration);}
  }
}
//----------------------------------GAMES FUNCTIONS-------------------------------------------------------------------------
void playChoice(char what,int R,int G,int B){                                                          //Opted for Yellow
      allSameColor(1,R,G,B);                                            //Yellow
      FastLED.show(); 
      playNote(what,800);
      delay(150);
      digitalWrite(musicPin,LOW);    
}


void playMemory(){
  randomSeed(analogRead(0));
  int turn=1;
  String quest="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ";
  String solution="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ";
  for(int i=0;i<50;i++){
    int question=random(1,5);
    switch(question){
      case 1:
      quest.setCharAt(i,'c');
      break;
      case 2:
      quest.setCharAt(i,'e');
      break;
      case 3:
      quest.setCharAt(i,'g');
      break;
      case 4:
      quest.setCharAt(i,'b');
      break;
    }
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("HOW STRONG");  
  lcd.setCursor(0, 1);
  lcd.print("IS YOUR MEMORY ?");  
  
  int color;
  
  for(int i=0;i<sizeof(songPlayMemory1)-1;i++){                          //Music at the start
    if(songPlayMemory1[i]==' '){
      delay(beatsPlayMemory1[i]*tempoPlayMemory1);
    }
      else{    
      if(i==0 || i==2 || i==4 || i==6){color=0;}
      if(i==1 || i==3 || i==5 || i==7 || i==9|| i==11){color=1;}
      if(i==8 || i==12){color=2;}
      if(i==10){color=3;}
    
      switch(color){
      case 0:
      allSameColor(1,0, 0, 255);                                          //Blue
      break;
      case 1:
      allSameColor(1,255, 255, 0);                                        //Yellow     
      break;
      case 2:
      allSameColor(1,255, 0, 0);                                          //Green   
      break;
      case 3:
      allSameColor(1,255, 0, 0);                                          //Red  
      break;
      }     
      FastLED.show(); 
      playNote(songPlayMemory1[i],beatsPlayMemory1[i]*tempoPlayMemory1);
      delay(tempoPlayMemory1/2);
      }
      digitalWrite(musicPin,LOW);     
  } // end of music
  delay(500);
  
  for(int s=0;s<3;s++){
  allSameColor(s,0,0,0);
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("PUSH 1 TO START");  
  while (digitalRead(9)!=LOW){ }                                          //Button1=9 button2=6 button3=5 button4=3
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("HERE WE GO !"); 
  delay(1000);
  
  for(int i=0;i<50;i++){ 
    for(int j=0;j<turn;j++){ 
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("REPEAT AFTER ME"); 
    
      if(quest.charAt(j)==' '){
      delay(600);
      }
      else{    
        if(quest.charAt(j)=='c'){color=0;}
        if(quest.charAt(j)=='e'){color=1;}
        if(quest.charAt(j)=='g'){color=2;}
        if(quest.charAt(j)=='b'){color=3;}
    
      switch(color){
      case 0:
      for (int j=0;j<27;j++){
          allSameColor(1,0, 0, 255);                                        //Blue
        }
      break;
      case 1:
      for (int j=0;j<27;j++){
          allSameColor(1,255, 255, 0);                                      //Yellow
        }
      break;
      case 2:
      for (int j=0;j<27;j++){
          allSameColor(1,255, 0, 0);                                        //Green
        }
      break;
      case 3:
      for (int j=0;j<27;j++){
          allSameColor(1,0, 255, 0);                                        //Red
        }
      break;
      }     
      FastLED.show(); 
      playNote(quest[j],600);
      delay(300/2);
      }
      digitalWrite(musicPin,LOW);     
  }                                                                         // end of music
  
   for(int i=0;i<turn;i++){   
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.setCursor(0,1);
    lcd.print("G"); 
    lcd.setCursor(5,1);
    lcd.print("Y"); 
    lcd.setCursor(10,1);
    lcd.print("B");
    lcd.setCursor(15,1);
    lcd.print("R"); 
    
    while (digitalRead(9)!=LOW && digitalRead(6)!=LOW && digitalRead(5)!=LOW && digitalRead(3)!=LOW){  // button1=9 button2=6 button3=5 button4=3
    }
    if(digitalRead(3)==LOW){                                                  //Opted for Red
     playChoice('g',255,0,0);  
     if(quest.charAt(i)=='g'){lcd.setCursor(0,0);
      lcd.print("RIGHT           ");  
     }else{
        lcd.setCursor(0,0);
      lcd.print("     WRONG      ");
      wrong=true;
      }
    }
    if(digitalRead(6)==LOW){
     playChoice('e',255,255,0);                                               //Opted for Yellow   
     if(quest.charAt(i)=='e'){lcd.setCursor(0,0);
      lcd.print("RIGHT           "); }else{lcd.setCursor(0,0);
      lcd.print("     WRONG      ");
      wrong=true;
      }
    }
   if(digitalRead(5)==LOW){                                                   //Opted for Blue
    playChoice('c',0,0,255); 
     if(quest.charAt(i)=='c'){lcd.setCursor(0,0);
      lcd.print("RIGHT           "); }else{lcd.setCursor(0,0);
      lcd.print("     WRONG      ");
      wrong=true;
      }
    }
    if(digitalRead(9)==LOW){                                                  //Opted for Green
     playChoice('b',0,255,0);
     if(quest.charAt(i)=='b'){lcd.setCursor(0,0);
      lcd.print("RIGHT           "); }else{lcd.setCursor(0,0);
      lcd.print("     WRONG      "); 
      wrong=true;
      }
    }
    
    if(wrong==true){break;}
    delay(500);
    lcd.clear();
   } 
   
   delay(500);
   if (wrong==true){
      wrong=false;
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("YOUR SCORE = ");
      lcd.print(turn-1);    
      for(int i=0;i<sizeof(songPlayMemory1)-11;i++){  
        if(songPlayMemory1[i]==' '){
         delay(beatsPlayMemory1[i]*tempoPlayMemory1);
        }
        else{       
        FastLED.show(); 
        playNote(songPlayMemory1[i],beatsPlayMemory1[i]*tempoPlayMemory1*6);
        delay(tempoPlayMemory1/2);
        }
        digitalWrite(musicPin,LOW);     
      } // end of music 
      delay(2000);
      return;
    } 
turn++;
}
  }
//----------------------------------IR FUNCTIONS----------------------------------------------------------------------------
int checkIR(){
  if (myreceiver.decode(&myinput)) {                                            //Check for an IR signal  
    lastIRcode=myinput.value;                                                   //Get the IR code sent
    myreceiver.resume();
  }                   
    return lastIRcode;      
}

void whatIsTheIRcode(){
  lastIRcode=checkIR();                                                         //Check for IR signal         
      delay(250);                                                               //Delay to avoid doubleclick
}
//----------------------------------THE PROGRAMS----------------------------------------------------------------------------
void executeReset(){
  lcd.clear();
  lcd.setCursor(0, 0);                      
  lcd.print("RESETTING       ");
  command = 0;            
  previousCode =0;        
  lastIRcode = 0; 
  for(int s=0;s<3;s++){
  allSameColor(s,0,0,0);
  }
  repeatlight=0;
  delay(2000);
}
 
void repeatEffect(int howmany, int UPDATES, int twostrips){
 static uint8_t startIndex = 0;
 for (int cycles=1;cycles<howmany;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
        FillLEDsFromPaletteColors0(startIndex);
        FillLEDsFromPaletteColors(startIndex,twostrips);  
        FastLED.show();
        FastLED.delay(1000/UPDATES);
      }
    }
}    

void endOfCase(){
  if(repeatlight==command-3){
      command--;
    }
    command++;
} 
 
 void makeItHappen(){
  int snakelength=5;
  if(command < 1 || command > 40){command = 1;}                                 //Protect software switch(command) to overflow
  switch(command){
    case 1:
    allSameColor(0,255,255,255);                                                //All white at outer ring at start
    lcd.clear();
    lcd.setCursor(0, 0);                                                        //Print startmessage to the LCD.  
    lcd.print("           HELLO! Welcome "); 
    lcd.setCursor(0, 1);                    
    lcd.print("          to the LIGHT-BOX"); 
      for (int positionCounter = 0; positionCounter < 10; positionCounter++) {
        lcd.scrollDisplayLeft();                                                //Scroll one position left:
        delay(300);
        }       
      for (int i=0;i<3;i++){
        lcd.noDisplay();
        delay(500);
        lcd.display();
        delay(500);
        } 
    command++;
    lcd.clear();
    break;
      
    case 2: 
    lcd.clear();
    lcd.setCursor(0, 0);                      
    lcd.print("1=LIGHT 2=GUARD"); 
    lcd.setCursor(0, 1);                    
    lcd.print("     3=GAME");  
    break;
    
    case 3:
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("REPEAT LIGHT#");  
    lcd.setCursor(0, 1);
    lcd.print("1>> 2<< 4 ENTER");
    while(command==3){
      lastIRcode=0;
      whatIsTheIRcode();
      if(lastIRcode==12495 || digitalRead(9)==LOW){repeatlight++;}              //1=up
      if(lastIRcode==6375 || digitalRead(6)==LOW){repeatlight--;}               //2=down
      if(repeatlight<0 || repeatlight>20){repeatlight=0;}
      if(lastIRcode==4335 || digitalRead(3)==LOW){                              //4=enter
        if(repeatlight==0){command=4;}else{command=repeatlight+3;}
        lcd.setCursor(0, 1);
        lcd.print("                ");
        lcd.setCursor(0, 1);
        lcd.print("LIGHTS ON !!");
        delay(200);     
    }
   
    lcd.setCursor(14, 0);
    lcd.print(repeatlight); 
    }
    break;
    
    case 4:                                                                     //Light effect: outside in inside out white
    lcdProgramMessage();
    lcdTitles("OUTSIDE IN      ");
    for(int j=1;j<3;j++){
      for(int i=20;i>-1;i--){
        leds[0][i]=CRGB(255,255,255);
        FastLED.show();
        if(i<21-snakelength){leds[0][i+snakelength]=CRGB(0,0,0);}
        else{leds[1][6+21-snakelength-i]=CRGB(0,0,0);}      
        FastLED.show();
        delay(101-snakelength*5);
      }
      for(int i=0;i<27;i++){
        leds[1][i]=CRGB(255,255,255);
        FastLED.show();
        if(i>snakelength-1){leds[1][i-snakelength]=CRGB(0,0,0);}
        else{leds[0][snakelength-1-i]=CRGB(0,0,0);}     
        FastLED.show();
        delay(101-snakelength*10);
      }
      for(int i=0;i<27;i++){
        leds[2][i]=CRGB(255,255,255);
        FastLED.show();
        if(i>snakelength-1){leds[2][i-snakelength]=CRGB(0,0,0);}
        else{leds[1][27-snakelength+i]=CRGB(0,0,0);}     
        FastLED.show();
        delay(101-snakelength*15);
      }
      for(int i=0;i<7;i++){
        leds[1][i]=CRGB(255,255,255);
        FastLED.show();
        if(i>snakelength-1){leds[1][i-snakelength]=CRGB(0,0,0);}
        else{leds[2][27-snakelength+i]=CRGB(0,0,0);}     
        FastLED.show();
        delay(101-snakelength*20);
      }
    }
    fill_solid(leds[0], num_leds[0], CRGB(255,255,255));
    fill_solid(leds[1], num_leds[1], CRGB(255,255,255));
    FastLED.show();
    delay(1000);  
    endOfCase();
    break;
    
    case 5:                                                                     //Light effect: rainbow linearblend
    lcdProgramMessage();
    lcdTitles("RAINBOW         ");  
    currentPalette = RainbowColors_p;currentBlending = LINEARBLEND;
    repeatEffect(4,100,1);
    endOfCase();
    break;
    
    case 6:                                                                     //Light effect: rainbow stripe
    lcdProgramMessage();                
    lcdTitles("RAINBOW STRIPE  ");  
    currentPalette = RainbowStripeColors_p;currentBlending = NOBLEND;
    repeatEffect(4,150,1);
    endOfCase();
    break;
   
    case 7:                                                                     //Light effect: clouds
    lcdProgramMessage();                   
    lcdTitles("CLOUDS          ");  
    currentPalette = CloudColors_p;currentBlending = LINEARBLEND;
    repeatEffect(3,100,2);
    endOfCase();
    break;
    
    case 8:                                                                     //Light effect: lava linearblend
    lcdProgramMessage();             
    lcdTitles("LAVA            ");  
    currentPalette = LavaColors_p;currentBlending = LINEARBLEND;
    repeatEffect(6,500,1);
    endOfCase();
    break;
    
    case 9:                                                                     //Light effect: Stroboscope
    lcdProgramMessage();             
    lcdTitles("STROBO          ");  
      for(startIndex=0;startIndex<5;startIndex++){
       randomhits(); 
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    endOfCase();
    break;
    
    case 10:                                                                    //Light effect: Ocean linearblend
    lcdProgramMessage();                 
    lcdTitles("OCEAN           ");  
    currentPalette = OceanColors_p;currentBlending = LINEARBLEND;
    repeatEffect(3,50,1);
    endOfCase();
    break;
    
    case 11:                                                                    //Light effect: Heatcolors
    lcdProgramMessage();                 
    lcdTitles("HEAT            ");  
    currentPalette = HeatColors_p;currentBlending = LINEARBLEND;
    repeatEffect(4,100,2);
    endOfCase();
    break;
    
    case 12:                                                                   //Light effect: Confetti
    lcdProgramMessage();                   
    lcdTitles("CONFETTI         ");    
    static uint8_t startIndex = 0;
    for (int cycles=1;cycles<4;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
        confetti();
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    }
    endOfCase();
    break;
        
    case 13:                                                                    //Light effect: Forest colors linearblend
    lcdProgramMessage();                
    lcdTitles("FOREST          ");  
    currentPalette = ForestColors_p;currentBlending = LINEARBLEND;
    repeatEffect(4,150,2);
    endOfCase();
    break;
    
    case 14:                                                                    //Light effect: Lightning
    lcdProgramMessage();                   
    lcdTitles("LIGHTNING");  
      for(startIndex=0;startIndex<30;startIndex++){
       lightning();
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    endOfCase();
    break;
    
    case 15:                                                                    //Light effect: purple and green linear blend
    lcdProgramMessage();                   
    lcdTitles("PURPLE & GREEN  ");  
    SetupPurpleAndGreenPalette();currentBlending = LINEARBLEND;
    repeatEffect(4,100,3);
    endOfCase();
    break;
    
    case 16:                                                                    //Light effect: Sinelon
    lcdProgramMessage();                    
    lcdTitles("KIT         ");  
     for (int cycles=1;cycles<5;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
        sinelon(0,gHue,13); 
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    }
    endOfCase();
    break;
    
    case 17:                                                                   //Light effect: random pallette
    lcdProgramMessage();                   
    lcdTitles("RANDOM          ");  
    SetupTotallyRandomPalette();currentBlending = LINEARBLEND;
    repeatEffect(3,100,2);
    endOfCase();
    break;
    
    case 18:                                                                   //Light effect: Black and White stripes
    lcdProgramMessage();                   
    lcdTitles("BLACK & WHITE   ");  
    SetupBlackAndWhiteStripedPalette();currentBlending = NOBLEND;
    repeatEffect(3,150,1);
    endOfCase();
    break; 
    
    case 19:                                                                   //Light effect: Juggle
    lcdProgramMessage();                    
    lcdTitles("JUGGLE          ");  
     for (int cycles=1;cycles<3;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
       juggle(); 
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    }
    endOfCase();
    break;
        
    case 20:                                                                   //Light effect: BPM
    lcdProgramMessage();               
    lcdTitles("HEARTBEAT      ");  
     for (int cycles=1;cycles<5;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
        bpm(); 
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    }
    endOfCase();
    break;
    
    case 21:                                                                  //Light effect: Rainbow with Glitter
    lcdProgramMessage();                  
    lcdTitles("RAINBOW GLITTER ");  
     for (int cycles=1;cycles<4;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
       rainbowWithGlitter(); 
        FastLED.show();  
        FastLED.delay(1000/150); 
      }
    }
    endOfCase();
    break;
    
    case 22:                                                                 //Light effect: Flash
    lcdProgramMessage();                 
    lcdTitles("FLASH");  
      for(startIndex=0;startIndex<7;startIndex++){
       flash2strips();
        FastLED.show();  
        FastLED.delay(1000/500); 
      }
    endOfCase();
    break;
    
    case 23:                                                                 //Light effect: Wiper
    lcdProgramMessage();                 
    lcdTitles("WIPER");  
     for (int cycles=1;cycles<5;cycles++){ 
      for(startIndex=0;startIndex<255;startIndex++){
        sinelon(20,HUE_GREEN,39); 
        FastLED.show();  
        FastLED.delay(1000/750); 
      }
    }
    endOfCase();
    command=4;
    break;      
//----------------------------------GUARD SECTION---------------------------------------------------------------------------
      case 38:  
      lcd.setCursor(0, 0);
      lcd.print("        4 = STOP");               
      lcdTitles("GUARDING        ");  
      while(command==38){ 
        Serial.println(analogRead(A0));
        delay(500);
          if(analogRead(A0)>410){           
            for(startIndex=0;startIndex<255;startIndex++){
            sinelon(0,HUE_BLUE,13); 
            FastLED.show();  
            FastLED.delay(1000/150); 
      }
          }else{
              for(int s=0;s<3;s++){
              allSameColor(s,0,0,0);
              }
            }
        if(digitalRead(3)==LOW){executeReset();}
        }
      break;
//----------------------------------GAME SECTION---------------------------------------------------------------------------      
      case 40:
      lcdProgramMessage();
      for(int s=0;s<3;s++){
        allSameColor(s,0,0,0);
        }
      playMemory();
      executeReset();
      break;
    }   
  return;
  }
 
//------------------------------------------------------------------------- 
void setup() {   
  delay( 3000 );                                                              //Power-up safety delay
  FastLED.addLeds<WS2811, DATA_PIN0, GRB>(leds[0], num_leds[0]).setCorrection( TypicalLEDStrip );
  FastLED.addLeds<WS2811, DATA_PIN1, GRB>(leds[1], num_leds[1]).setCorrection( TypicalLEDStrip ); 
  FastLED.addLeds<WS2811, DATA_PIN2, GRB>(leds[2], num_leds[2]).setCorrection( TypicalLEDStrip );  
  currentPalette = RainbowColors_p;
  currentBlending = LINEARBLEND;
   
  Serial.begin(9600);                                                         //Connect to serial monitor
  myreceiver.enableIRIn();                                                    //Start IR receiver
  
  pinMode(3,INPUT);                                                           //Key1 'DOWN'
  pinMode(5,INPUT);                                                           //Key2 'UP'
  pinMode(6,INPUT);                                                           //Key3 'DOWN'
  pinMode(9,INPUT);                                                           //Key4 'UP'  
  pinMode(A0,INPUT);                                                          //Lightsensor
  pinMode(musicPin,OUTPUT);                                                   //Set music pin
  
  lcd.begin(16, 2);                                                           //Intialise LCD 
  lcd.clear();
     
  FastLED.setBrightness(255);                                                 // Set masterbrightness (0-255)   
}

void loop() {

if(command!=0){
  previousCode=lastIRcode;
  whatIsTheIRcode();
}

if(command > 4 && lastIRcode!=previousCode){executeReset();}

makeItHappen();

if((command==2 && lastIRcode==12495)||(command==2 && digitalRead(9)==LOW)){   //Choosing lights
  command = 3;
  }
if((command==2 && lastIRcode==6375)||(command==2 && digitalRead(6)==LOW)){   //Choosing guard
  command=38;
  }
if((command==2 && lastIRcode==31365)||(command==2 && digitalRead(5)==LOW)){   //Choosing games
  command=40;
  }
if((command==2 && lastIRcode==4335)||(command==2 && digitalRead(3)==LOW)){   //Choosing menu
  lcd.clear();
  lcd.print("4       ");  
  }

}

Schematics

lamp_fritzing_kzT34rfAxC.fzz
lamp_fritzing_kzT34rfAxC.fzz
Light-Box
Fritzing breadboard schema lamp axgeesuean

Comments

Similar projects you might like

Light Intensity and Solar Panel Energy Detector

Project tutorial by Kutluhan Aktar

  • 1,727 views
  • 4 comments
  • 10 respects

Kid's Majestic Streamer Fan Light Button Box

Project in progress by Team Max 35

  • 1,685 views
  • 0 comments
  • 0 respects

Light Sequence Creator

Project tutorial by Reid Paulhus

  • 6,470 views
  • 2 comments
  • 16 respects

Control your light with Arduino

Project tutorial by GiorgioTraverso

  • 1,807 views
  • 0 comments
  • 2 respects

Arduino Audio Reactive Desk Light

Project tutorial by Haziq Azri

  • 12,626 views
  • 5 comments
  • 30 respects
Add projectSign up / Login