Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FASTLED_INTERNAL
- #include <FastLED.h>
- #include <Wire.h>
- #define NUM_LEDS 3 // NUMBER OF PIXELS IN THE USED STRIP
- #define DATA_PIN 6
- uint16_t currentPixel = 0; // SET TO PIXEL NUMBER 0
- uint16_t led = 0;
- //-----------TIMING------------
- unsigned long currentMillis = 0;
- unsigned long previousMillis = 0;
- unsigned long speedOfEveningToMorning = 500; // DURATION IN STEPS OF nightcycle ROUTINE - 6steps/second (1 minute = 360 steps)
- unsigned long speedOfMorningToEvening = 500; // DURATION IN STEPS OF daycle ROUTINE - 6steps/second (1 minute = 360 steps)
- unsigned long timeBaseInterval = speedOfMorningToEvening + speedOfEveningToMorning; // TIMEBASE FOR THE nightcycle + daycycle
- unsigned long time_Now = 0;
- byte maxBrightness = 150; // VALUES FROM 0 - 255 -> THE HIGHER, THE MORE Amps NEEDED - FOR THE LED STRIPS
- static const float intervalMorningToEvening = speedOfMorningToEvening;
- static const float intervalEveningToMorning = speedOfEveningToMorning;
- DEFINE_GRADIENT_PALETTE (AM_gp) { // Midnight To Noon (amCycle)
- 0, 0, 0, 0, //black
- 18, 0, 0, 0, //dark red
- 56, 161, 83, 0, //orange
- 115, 212, 202, 0, //dark yellow
- 179, 255, 253, 213, //bright yellow
- 255, 255, 255, 255, //white
- };
- DEFINE_GRADIENT_PALETTE (PM_gp) { // Noon to Midnight (pmCycle)
- 0, 255, 255, 255, //white
- 18, 255, 253, 213, //bright yellow
- 56, 212, 202, 0, //dark yellow
- 115, 161, 83, 0, //orange
- 179, 98, 0, 0, //dark red
- 255, 0, 0, 0 //black
- };
- CRGBPalette16 AMPal = AM_gp;
- CRGBPalette16 PMPal = PM_gp;
- struct CRGB leds[NUM_LEDS];
- static uint8_t paletteIndex = 0;
- //*********************************************************************
- //Setup
- void setup() {
- Serial.begin(9600);
- FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
- }
- //*****************************************************************************
- //Loop
- void loop() {
- CRGB coloram = ColorFromPalette(AMPal, paletteIndex, maxBrightness, LINEARBLEND);
- fill_solid(leds, NUM_LEDS, coloram);
- EVERY_N_MILLISECONDS(500) { //set this number to set the lenght of your first half of the 24 hour period.
- while (paletteIndex < 255) {
- paletteIndex++;
- }
- if (paletteIndex == 255) {
- paletteIndex = 0;
- FastLED.show();
- }
- CRGB colorpm = ColorFromPalette(PMPal, paletteIndex, maxBrightness, LINEARBLEND);
- fill_solid(leds, NUM_LEDS, colorpm);
- EVERY_N_MILLISECONDS(500) { //set this number to set the lenght of your second half of the 24 hour period.
- while (paletteIndex < 255) {
- paletteIndex++;
- }
- if (paletteIndex == 255) {
- paletteIndex = 0;
- }
- FastLED.show();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement