Advertisement
kartonman

daily cycl2 2 pallets

Sep 5th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1.  
  2. #define FASTLED_INTERNAL
  3. #include <FastLED.h>
  4. #include <Wire.h>
  5.  
  6.  
  7. #define NUM_LEDS 3 // NUMBER OF PIXELS IN THE USED STRIP
  8. #define DATA_PIN 6
  9.  
  10. uint16_t currentPixel = 0; // SET TO PIXEL NUMBER 0
  11. uint16_t led = 0;
  12.  
  13.  
  14. //-----------TIMING------------
  15.  
  16. unsigned long currentMillis = 0;
  17. unsigned long previousMillis = 0;
  18.  
  19. unsigned long speedOfEveningToMorning = 500; // DURATION IN STEPS OF nightcycle ROUTINE - 6steps/second (1 minute = 360 steps)
  20. unsigned long speedOfMorningToEvening = 500; // DURATION IN STEPS OF daycle ROUTINE - 6steps/second (1 minute = 360 steps)
  21.  
  22. unsigned long timeBaseInterval = speedOfMorningToEvening + speedOfEveningToMorning; // TIMEBASE FOR THE nightcycle + daycycle
  23. unsigned long time_Now = 0;
  24.  
  25. byte maxBrightness = 150; // VALUES FROM 0 - 255 -> THE HIGHER, THE MORE Amps NEEDED - FOR THE LED STRIPS
  26.  
  27.  
  28. static const float intervalMorningToEvening = speedOfMorningToEvening;
  29. static const float intervalEveningToMorning = speedOfEveningToMorning;
  30.  
  31.  
  32. DEFINE_GRADIENT_PALETTE (AM_gp) { // Midnight To Noon (amCycle)
  33. 0, 0, 0, 0, //black
  34. 18, 0, 0, 0, //dark red
  35. 56, 161, 83, 0, //orange
  36. 115, 212, 202, 0, //dark yellow
  37. 179, 255, 253, 213, //bright yellow
  38. 255, 255, 255, 255, //white
  39. };
  40. DEFINE_GRADIENT_PALETTE (PM_gp) { // Noon to Midnight (pmCycle)
  41. 0, 255, 255, 255, //white
  42. 18, 255, 253, 213, //bright yellow
  43. 56, 212, 202, 0, //dark yellow
  44. 115, 161, 83, 0, //orange
  45. 179, 98, 0, 0, //dark red
  46. 255, 0, 0, 0 //black
  47. };
  48.  
  49. CRGBPalette16 AMPal = AM_gp;
  50. CRGBPalette16 PMPal = PM_gp;
  51.  
  52. struct CRGB leds[NUM_LEDS];
  53. static uint8_t paletteIndex = 0;
  54.  
  55. //*********************************************************************
  56. //Setup
  57.  
  58. void setup() {
  59. Serial.begin(9600);
  60. FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  61. }
  62.  
  63. //*****************************************************************************
  64. //Loop
  65.  
  66. void loop() {
  67. CRGB coloram = ColorFromPalette(AMPal, paletteIndex, maxBrightness, LINEARBLEND);
  68. fill_solid(leds, NUM_LEDS, coloram);
  69.  
  70. EVERY_N_MILLISECONDS(500) { //set this number to set the lenght of your first half of the 24 hour period.
  71. while (paletteIndex < 255) {
  72. paletteIndex++;
  73. }
  74. if (paletteIndex == 255) {
  75. paletteIndex = 0;
  76. FastLED.show();
  77. }
  78. CRGB colorpm = ColorFromPalette(PMPal, paletteIndex, maxBrightness, LINEARBLEND);
  79. fill_solid(leds, NUM_LEDS, colorpm);
  80. EVERY_N_MILLISECONDS(500) { //set this number to set the lenght of your second half of the 24 hour period.
  81. while (paletteIndex < 255) {
  82. paletteIndex++;
  83. }
  84. if (paletteIndex == 255) {
  85. paletteIndex = 0;
  86. }
  87. FastLED.show();
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement