Final Video

This is my finished project: I have finished building the table and I managed to make the patterns work remotely via an IR receiver and a universal remote. Any universal remote should work, but be wary because the receiver can be sensitive so you would want to be sure the wiring is correct; I’m going to post a schematic below, along with my documentation.

 

20150723_141712 (2)

 

Milestone

In this video I was able to get my LED strip for my main project to work via button push. This video is considered a milestone, due to the fact that all that is needed now is to add the LED’s and mirrors to the table.

 

Starter Project Video

In this video, I explain how exactly my mini piano starter project works, and some of the problems I had while creating this tiny masterpiece.

The video:

Documentation

Bill of Materials

CAD

 

This is my code(below), as a reminder. It is meant for the Arduino Uno, but may work on the MEGA. This code also requires an IR receiver. I recommend getting multiple IR receivers, due to the fact that they are sensitive and easy to burn out (I learned from experience).

//——————-LIBRARIES AND VARIABLES——————————————————
//————————————————————————————————
#include <IRremote.h>
#include <IRremoteInt.h>
#include <FastLED.h>

#define LED_PIN 6
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 68

#define COOLING 55
#define SPARKING 120
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 60
CRGB leds[NUM_LEDS];

int receiverpin = 3;
IRrecv irrecv(receiverpin); // create instance of irrecv
decode_results results;

//————————END LIBRARIES AND VARIABLES———————————————--
//————————————————————————————————--

//———————————-BEGIN SETUP—————————————————--
//————————————————————————————————--

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // start the IR receiver
delay(1000); // sanity delay
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(BRIGHTNESS);
randomSeed(analogRead(3));
FastLED.addLeds<NEOPIXEL,LED_PIN>(leds, NUM_LEDS);

}
//———————--END SETUP——————————-
//—————————————————————

//———————--MAIN CODE——————————-
//—————————————————————
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value);
switch (results.value)
{
case 544993039:
while(results.value == 544993030)
{
random16_add_entropy( random());
Fire2012(); // run simulation frame
FastLED.show(); // display this frame
FastLED.delay(1000 / FRAMES_PER_SECOND);

delay(2000);
}
case 3896860046:
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1)
{
leds[whiteLed] = CRGB::Cyan;
FastLED.show();
delay(100);
leds[whiteLed] = CRGB::Red;
}
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}

case 3417827657: //red white and blue
patriot();
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}
case 2422134005:
Fire2012();
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}

case 740241778: //rainbow
rainbow();
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}
case 990610224: //display 30 random colors
for (int i=0; i<5; i++)
{
randomPattern();
Serial.println(i);
}
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}

// Power button
case 4045713590:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Black;
}
FastLED.show();
delay(500);
if (irrecv.decode(&results))
{
Serial.println(results.value);
break;
}
}
irrecv.resume();
}
}
//————————--END VOID LOOP—————————--
//——————————————————————--

//——————--FOR RANDOM PATTERN———————————-
//——————————————————————--
void randomPattern()
{
int selection = random(1, 11);
switch (selection)
{
case 1:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Red;
}
FastLED.show();
delay(1000);
case 2:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Blue;
}
FastLED.show();
delay(1000);
case 3:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Magenta;
}
FastLED.show();
delay(1000);
case 4:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Green;
}
FastLED.show();
delay(1000);
case 5:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Cyan;
}
FastLED.show();
delay(1000);
case 6:
for (int j=0; j<NUM_LEDS; j++)
{
leds[j] = CRGB::Yellow;
}
FastLED.show();
delay(1000);
case 7:
rainbow();
delay(1000);
case 8:
hot();
delay(1000);
case 9:
cool();
delay(1000);
case 10:
patriot();
delay(1000);
case 11:
for (int h=0; h<68; h++)
{
random16_add_entropy( random());
Fire2012();
FastLED.show();
FastLED.delay(10000 / FRAMES_PER_SECOND);
}
case 12:
Cylon();
delay(1000);

}
}
//——————————-END CHANGE PATTERN——————-
//——————————————————————--
//ADD ALL FUNCTIONS FOR PATTERNS

//—————————-FUNCTION—————————
//—————————————————————
void Fire2012()
{
// Array of temperature readings at each simulation cell
static byte heat[NUM_LEDS];

// Step 1. Cool down every cell a little
for( int i = 0; i < NUM_LEDS; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}

// Step 2. Heat from each cell drifts ‘up’ and diffuses a little
for( int k= NUM_LEDS – 1; k >= 2; k--) {
heat[k] = (heat[k – 1] + heat[k – 2] + heat[k – 2] ) / 3;
}

// Step 3. Randomly ignite new ‘sparks’ of heat near the bottom
if( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160,255) );
}

// Step 4. Map from heat cells to LED colors
for( int j = 0; j < NUM_LEDS; j++) {
leds[j] = HeatColor( heat[j]);
}
}
//——————————————————————————--
//———————————-END FUNCTION———————————--

void patriot()
{
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 3)
{
leds[whiteLed] = CRGB::Blue;
leds[whiteLed-1] = CRGB::Red;
leds[whiteLed-2] = CRGB::White;
FastLED.show();
delay(100);
}
}

void hot()
{
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 4)
{
leds[whiteLed] = CRGB::Red;
leds[whiteLed-1] = CRGB::Orange;
leds[whiteLed-2] = CRGB::Yellow;
leds[whiteLed-3] = CRGB::White;
FastLED.show();
delay(100);
}
}
void cool()
{
for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 5)
{
leds[whiteLed] = CRGB::Teal;
leds[whiteLed-1] = CRGB::Cyan;
leds[whiteLed-2] = CRGB::Blue;
leds[whiteLed-3] = CRGB::Magenta;
leds[whiteLed-4] = CRGB::White;
FastLED.show();
delay(100);
}
}

void rainbow()
{
for(int whiteLed = 5; whiteLed < NUM_LEDS; whiteLed = whiteLed + 6)
{
leds[whiteLed] = CRGB::Red;
leds[whiteLed-1] = CRGB::Orange;
leds[whiteLed-2] = CRGB::Yellow;
leds[whiteLed-3] = CRGB::Green;
leds[whiteLed-4] = CRGB::Blue;
leds[whiteLed-5] = CRGB::Magenta;
FastLED.show();
delay(100);
}
}
void Cylon()
{
for(int i = 0; i < NUM_LEDS; i++)
{

leds[i] = CRGB::Green;
FastLED.show();
leds[i] = CRGB::White;
delay(30);
}

// Now go in the other direction.
for(int i = NUM_LEDS-3; i >= 0; i--)
{
// Set the i’th led to red
leds[i] = CRGB::Cyan;
FastLED.show();
leds[i] = CRGB::Magenta;
leds[i] = CRGB::Yellow;
delay(30);
}
}

//—————————--THIS IS A FUNCTION————————————
//———————————————————————————--
void FirstLight ()
{
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
}
//——————————————————————--
//———————END FUNCTION———————————--

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering