/*************************************************************************************** Ten LEDs Lighting for One Knob Boards Code Made for DAC Power Button Including LEDs Animation for DAC Status Information Author: Corentin Mornet Project: echo DAC Date: January 16th 2017 ***************************************************************************************/ #include "FastLED.h" #define NUM_LEDS 10 // Number of LEDs used #define PIN_LEDS 6 // Pin used for LEDs data #define SWITCH 4 // Pin used for On/Off Switch #define CONNECTED 2 // Pin used for NAS connection feedback from RaspberryPi CRGB leds[NUM_LEDS]; const int speedDelay = 50; const int startupColorR = 0xFF; // Start-up color, Red LED const int startupColorG = 0xFF; // Start-up color, Green LED const int startupColorB = 0xFF; // Start-up color, Blue LED const int connectedColorR = 0xFF; // Connected color, Red LED const int connectedColorG = 0xFF; // Connected color, Green LED const int connectedColorB = 0xFF; // Connected color, Blue LED const int animation = 2; // Select animation when NAS connection is established; 0: Twinkle, 1: ColorWipe, 2: TheaterChase, 3: RunningLights, 4: Cylon const float increment = 0.006; const float brightness = 1.8*PI; // Actual brightness used in functions; 1.5*PI is 0% and 2.5*PI is 100% brightness int steps = 0; void setup() { FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); pinMode(SWITCH,INPUT); // Input from selector switch pinMode(CONNECTED,INPUT); // Input from RaspberryPi setAll(0x00, 0x00, 0x00); // Starts with all turned off LEDs } void loop() { if (digitalRead(SWITCH) == HIGH) { switch (steps) { case 0: // STEP 1 : progressive start of the start-up color lighting { startLighting(startupColorR, startupColorG, startupColorB); delay(20*speedDelay); // 1s delay steps = 1; break; } case 1: // STEP 2 : LEDs animation while RapberryPi Starts and connects to NAS server { if (digitalRead(CONNECTED) == LOW) { switch (animation) { case 0: { twinkleLighting(connectedColorR, connectedColorG, connectedColorB, 10, true); break; } case 1: { colorWipeLighting(connectedColorR, connectedColorG, connectedColorB); colorWipeLighting(0x00, 0x00, 0x00); break; } case 2: { theaterChaseLighting(connectedColorR, connectedColorG, connectedColorB); break; } case 3: { runningLightsLighting(connectedColorR, connectedColorG, connectedColorB); break; } case 4: { cylonLighting(connectedColorR, connectedColorG, connectedColorB, 1); break; } } } else { setAll(0x00, 0x00, 0x00); delay(20*speedDelay); // 1s delay steps = 2; } break; } case 2: // STEP 3 : Animation of the connected color lighting depending on animation selected in constant { if (digitalRead(CONNECTED) == HIGH) { delay(20*speedDelay); // 1s delay steps = 3; } else { steps = 1; } break; } case 3: // STEP 3 :steady connected color lighting while ready { if (digitalRead(CONNECTED) == HIGH) { steadyLighting(connectedColorR, connectedColorG, connectedColorB); } else { stopLighting(connectedColorR, connectedColorG, connectedColorB); delay(20*speedDelay); // 1s delay steps = 1; } break; } } } else { setAll(0x00, 0x00, 0x00); steps = 0; } }