Last active
June 18, 2017 14:32
-
-
Save PaulWieland/db9b2cb9bb8934da739efd31ec724eb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FastLED.h" | |
// V = Vanity | |
// N = Nightlight | |
#define LED_TYPE WS2811 | |
#define COLOR_ORDER GRB | |
#define V_TRIGGER_PIN 6 | |
#define N_TRIGGER_PIN 5 | |
#define V_DATA_PIN 12 | |
#define N_DATA_PIN 11 | |
#define V_NUM_LEDS 216 | |
#define N_NUM_LEDS 58 | |
CRGB V_leds[V_NUM_LEDS]; | |
CRGB N_leds[N_NUM_LEDS]; | |
#define BRIGHTNESS 255 | |
//#define V_BRIGHTNESS 255 | |
//#define N_BRIGHTNESS 96 | |
#define FRAMES_PER_SECOND 120 | |
void setup() { | |
delay(3000); // 3 second delay for recovery | |
Serial.begin(115200); | |
// The pins the Insteon I/O Lincs relays will ground out when activated | |
pinMode(V_TRIGGER_PIN, INPUT_PULLUP); | |
pinMode(N_TRIGGER_PIN, INPUT_PULLUP); | |
// tell FastLED about the LED strip configuration | |
FastLED.addLeds<LED_TYPE,V_DATA_PIN,COLOR_ORDER>(V_leds, V_NUM_LEDS).setCorrection(TypicalLEDStrip).setTemperature(Tungsten100W); | |
FastLED.addLeds<LED_TYPE,N_DATA_PIN,COLOR_ORDER>(N_leds, N_NUM_LEDS).setCorrection(TypicalLEDStrip); | |
// set master brightness control | |
// How to control the brightness of the different strands individually?? | |
FastLED.setBrightness(BRIGHTNESS); | |
} | |
void loop() | |
{ | |
// vanityOn(); | |
if(digitalRead(V_TRIGGER_PIN) == LOW){ | |
vanityOn(); | |
}else{ | |
vanityOff(); | |
} | |
nightLightsOn(); | |
nightLightsOff(); | |
FastLED.show(); | |
FastLED.delay(1000/FRAMES_PER_SECOND); | |
} | |
void vanityOn() | |
{ | |
/* beatsin16 generates a sine wave which results in oscilation */ | |
// int pos = beatsin16(50,0,V_NUM_LEDS/4); | |
/* | |
* beat8 generates a sawtooth wave at X beats per minute | |
* ease8InOutQuad smooths the value somehow... | |
* Lerp is similar to map(). Converts a range into another range, just faster? | |
*/ | |
int pos = lerp8by8( 0, (V_NUM_LEDS/4), ease8InOutQuad( beat8( 40 ))) ; | |
int pos2 = pos + (V_NUM_LEDS / 2); | |
int pos3 = pos2 - (pos * 2); | |
int pos4 = V_NUM_LEDS - pos; | |
V_leds[pos - 1] = CHSV( 0, 0, 255); | |
V_leds[pos2 -1] = CHSV( 0, 0, 255); | |
V_leds[pos3 -1] = CHSV( 0, 0, 255); | |
V_leds[pos4 -1] = CHSV( 0, 0, 255); | |
Serial.println("pos: "+(String) pos2); | |
} | |
void vanityOff() | |
{ | |
fadeToBlackBy(V_leds, V_NUM_LEDS, 10); | |
} | |
void nightLightsOn() | |
{ | |
} | |
void nightLightsOff() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment