#include <FastLED.h>
// Set data pin and led count
#define VOLTS 5 // maximum 5volt power
#define PWR_LIMIT 500 // 500mA limit
#define LED_PIN 7 // data pin
#define NUM_LEDS 135 // single section for testing
#define BRIGHTNESS 150 // brightness level
#define LED_SECTIONS 3 // number of sections in display
CRGB leds [NUM_LEDS]; // initialize all pixels
// lighting order for each section
int section1[ ] = {44,0,43,1,42,2,41,3,40,4,39,5,38,6,37,7,36,35,34,8,33,32, 9,31,10,
30,11,29,12,28,13,27,14,26,15,25,16,24,17,23,18,22,19,21,20};
int section2[ ] = {79,78,80,77,81,76,82,75,83,74,84,73,85,72,86,71,87,88,89,70,69,45,
68,46,67,47,66,48,65,49,64,50,63,51,62,52,61,53,60,54,59,55,58,56,
57};
int section3[ ] = {111,110,112,109,113,108,114,107,115,106,116,105,117,104,118,103,
119,120,121,102,122,123,101,124,100,125,99,126,98,127,97,128,96,
129,95,130,94,131,93,132,92,133,91,134,90};
struct LedPair { // section 1
uint8_t led1;
uint8_t led2;
};
LedPair pairs[] = {
{44,44},{0,43},{1,42},{2,41},{3,40},{4,39},{5,38},{6,37},{7,36},{35,35},{8,34},{33,33},
{9,32},{10,31},{11,30},{12,29},{13,28},{14,27},{15,26},{16,25},{17,24},{18,23},{19,22},
{20,21}
};
struct LedPair1 { // section 2
uint8_t led1;
uint8_t led2;
};
LedPair pairs1[] = {
{79,79},{78,80},{77,81},{76,82},{75,83},{74,84},{73,85},{72,86},{71,87},{88,88},{70,89},
{69,69},{45,68},{46,67},{47,66},{48,65},{49,64},{50,63},{51,62},{52,61},{53,60},{54,59},
{55,58},{56,57}
};
struct LedPair2 { // section 3
uint8_t led1;
uint8_t led2;
};
LedPair pairs2[] = {
{111,111},{110,112},{109,113},{108,114},{107,115},{106,116},{105,117},{104,118},
{103,119},{120,120},{102,121},{122,122},{123,101},{124,100},{125,99},{126,98},{127,97},
{128,96},{129,95},{130,94},{131,93},{132,92},{133,91},{134,90}
};
struct LedPair3 { // outer ring
uint8_t led1;
uint8_t led2;
};
LedPair pairs3[] = {
{120,121},{122,102},{123,101},{124,100},{125,99},{126,98},{127,97},{128,96},
{129,95},{130,94},{131,93},{132,92},{133,91},{134,90},{89,88},{69,70},{45,68},
{46,67},{47,66},{48,65},{49,64},{50,63},{51,62},{52,61},{53,60},{54,59},{55,58},
{56,57},{35,34},{8,33},{9,32},{10,31},{11,30},{12,29},{13,28},{14,27},{15,26},
{16,25},{17,24},{18,23},{19,22},{20,21}
};
struct LedPair4 { // inner ring
uint8_t led1;
uint8_t led2;
};
LedPair pairs4[] = {
{}
};
void setup() {
/*********************************************************************************************
********************************* only runs once at start-up *********************************
*********************************************************************************************/
FastLED.setMaxPowerInVoltsAndMilliamps( VOLTS, PWR_LIMIT);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS); // type, data pin, clolour..
// ..order, num of pixels
FastLED.setBrightness(BRIGHTNESS); // set brightness level
FastLED.clear();
}
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = {demo1,demo2,demo3,demo4};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color"
void loop() {
/*********************************************************************************************
********************************* main code runs repeatedly **********************************
*********************************************************************************************/
gPatterns[gCurrentPatternNumber]();
FastLED.show();
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
EVERY_N_SECONDS( 6 ) { nextPattern(); } // change patterns periodically
}
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}
void demo1() {
FastLED.clear();
int wait = 100;
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs[thestrip].led1].setRGB(128,0,0);
leds[pairs[thestrip].led2].setRGB(128,0,0);
leds[pairs1[thestrip].led1].setRGB(128,128,0);
leds[pairs1[thestrip].led2].setRGB(128,128,0);
leds[pairs2[thestrip].led1].setRGB(0,0,128);
leds[pairs2[thestrip].led2].setRGB(0,0,128);
FastLED.show();
delay (wait);
}
delay(200);
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs[thestrip].led1].setRGB(0,0,0);
leds[pairs[thestrip].led2].setRGB(0,0,0);
leds[pairs1[thestrip].led1].setRGB(0,0,0);
leds[pairs1[thestrip].led2].setRGB(0,0,0);
leds[pairs2[thestrip].led1].setRGB(0,0,0);
leds[pairs2[thestrip].led2].setRGB(0,0,0);
FastLED.show();
delay (wait);
}
}
void demo2() {
int wait = 20;
for(int thestrip = 0; thestrip < 19; thestrip++){
leds[pairs[thestrip].led1].setRGB(128,0,0);
leds[pairs[thestrip].led2].setRGB(128,0,0);
leds[pairs1[thestrip].led1].setRGB(128,128,0);
leds[pairs1[thestrip].led2].setRGB(128,128,0);
leds[pairs2[thestrip].led1].setRGB(0,0,128);
leds[pairs2[thestrip].led2].setRGB(0,0,128);
FastLED.show();
delay (wait);
}
delay(200);
for(int thestrip = 18; thestrip >= 0; thestrip--){
leds[pairs[thestrip].led1].setRGB(0,0,0);
leds[pairs[thestrip].led2].setRGB(0,0,0);
leds[pairs1[thestrip].led1].setRGB(0,0,0);
leds[pairs1[thestrip].led2].setRGB(0,0,0);
leds[pairs2[thestrip].led1].setRGB(0,0,0);
leds[pairs2[thestrip].led2].setRGB(0,0,0);
FastLED.show();
delay (wait);
}
delay(500);
}
void demo3() {
FastLED.clear();
int wait = 40;
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs[thestrip].led1].setRGB(128,0,0);
leds[pairs[thestrip].led2].setRGB(128,0,0);
leds[pairs1[thestrip].led1].setRGB(128,128,0);
leds[pairs1[thestrip].led2].setRGB(128,128,0);
leds[pairs2[thestrip].led1].setRGB(0,0,128);
leds[pairs2[thestrip].led2].setRGB(0,0,128);
FastLED.show();
delay (wait);
}
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs[thestrip].led1].setRGB(0, 128, 0);
leds[pairs[thestrip].led2].setRGB(0, 128, 0);
leds[pairs1[thestrip].led1].setRGB(0, 128, 128);
leds[pairs1[thestrip].led2].setRGB(0, 128, 128);
leds[pairs2[thestrip].led1].setRGB(128, 0, 128);
leds[pairs2[thestrip].led2].setRGB(128, 0, 128);
FastLED.show();
delay (wait);
}
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs2[thestrip].led1].setRGB(128,0,0);
leds[pairs2[thestrip].led2].setRGB(128,0,0);
leds[pairs[thestrip].led1].setRGB(128,128,0);
leds[pairs[thestrip].led2].setRGB(128,128,0);
leds[pairs1[thestrip].led1].setRGB(0,0,128);
leds[pairs1[thestrip].led2].setRGB(0,0,128);
FastLED.show();
delay (wait);
}
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs2[thestrip].led1].setRGB(0, 128, 0);
leds[pairs2[thestrip].led2].setRGB(0, 128, 0);
leds[pairs1[thestrip].led1].setRGB(0, 128, 128);
leds[pairs1[thestrip].led2].setRGB(0, 128, 128);
leds[pairs[thestrip].led1].setRGB(128, 0, 128);
leds[pairs[thestrip].led2].setRGB(128, 0, 128);
FastLED.show();
delay (wait);
}
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs1[thestrip].led1].setRGB(128,0,0);
leds[pairs1[thestrip].led2].setRGB(128,0,0);
leds[pairs2[thestrip].led1].setRGB(128,128,0);
leds[pairs2[thestrip].led2].setRGB(128,128,0);
leds[pairs[thestrip].led1].setRGB(0,0,128);
leds[pairs[thestrip].led2].setRGB(0,0,128);
FastLED.show();
delay (wait);
}
for(int thestrip = 0; thestrip < 24; thestrip++){
leds[pairs1[thestrip].led1].setRGB(0, 128, 0);
leds[pairs1[thestrip].led2].setRGB(0, 128, 0);
leds[pairs[thestrip].led1].setRGB(0, 128, 128);
leds[pairs[thestrip].led2].setRGB(0, 128, 128);
leds[pairs2[thestrip].led1].setRGB(128, 0, 128);
leds[pairs2[thestrip].led2].setRGB(128, 0, 128);
FastLED.show();
delay (wait);
}
}
void demo4() {
FastLED.clear();
int wait = 50;
for(int thestrip = 0; thestrip < 42; thestrip++){
leds[pairs3[thestrip].led1].setRGB(128,128,0);
leds[pairs3[thestrip].led2].setRGB(128,128,0);
FastLED.show();
delay (wait);
}
delay(200);
for(int thestrip = 0; thestrip < 42; thestrip++){
leds[pairs3[thestrip].led1].setRGB(0,0,200);
leds[pairs3[thestrip].led2].setRGB(0,0,200);
FastLED.show();
delay (wait);
}
delay(200);
for(int thestrip = 0; thestrip < 42; thestrip++){
leds[pairs3[thestrip].led1].setRGB(0,128,0);
leds[pairs3[thestrip].led2].setRGB(0,128,0);
FastLED.show();
delay (wait);
}
delay(200);
}
void confetti() {
FastLED.clear();
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
FastLED.show();
}
void lamp() {
for (int thestrip = 0; thestrip < NUM_LEDS; thestrip++){
leds[thestrip].setRGB(128,128,128);
FastLED.show();
}
}