/*************************************************************************************** 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 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) { serverSearch(startupColorR, startupColorG, startupColorB, 10, true); } else { setAll(0x00,0x00,0x00); delay(20*speedDelay); // 1s delay steps = 2; } break; } case 2: // STEP 3 : progressive start of the connected color lighting { if (digitalRead(CONNECTED) == HIGH) { startedLighting(connectedColorR, connectedColorG, connectedColorB); 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; } }