Advertisement
kartonman

No Loop

Sep 10th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. //sunrise to sunset from timing sketch mod 2
  2.  
  3. #define FASTLED_INTERNAL
  4. #include <FastLED.h>
  5. #include <Wire.h>
  6.  
  7.  
  8. #define NUM_LEDS 3
  9. #define DATA_PIN 6
  10. #define pm 7
  11.  
  12.  
  13. int pmstate;
  14.  
  15. uint16_t currentPixel = 0;
  16. uint16_t led = 0;
  17. byte maxBrightness = 150;
  18.  
  19. //----------PALETTES-----------
  20.  
  21. DEFINE_GRADIENT_PALETTE (am_gp) {
  22. 0, 0, 0, 0,
  23. 18, 98, 0, 0,
  24. 56, 161, 83, 0,
  25. 115, 212, 202, 0,
  26. 179, 255, 253, 213,
  27. 255, 255, 255, 255
  28. };
  29. CRGBPalette16 myPal1 = am_gp;
  30.  
  31. struct CRGB leds[NUM_LEDS];
  32. static uint8_t paletteIndex = 0;
  33.  
  34. //------------SETUP-------------
  35.  
  36. void setup() {
  37. FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  38.  
  39. pinMode(pm, INPUT);
  40. }
  41. //------------LOOP-------------
  42.  
  43. void loop() {
  44.  
  45.  
  46. CRGB colour = ColorFromPalette(myPal1, paletteIndex, maxBrightness, LINEARBLEND);
  47. fill_solid(leds, NUM_LEDS, colour);
  48.  
  49. if (paletteIndex < 255) {
  50. EVERY_N_MILLISECONDS(100) {
  51. paletteIndex++;
  52. FastLED.show();}
  53. }
  54. else {
  55. if (paletteIndex > 0) {
  56. EVERY_N_MILLISECONDS(100) {
  57. paletteIndex--;
  58. FastLED.show();
  59. }
  60. }
  61. }
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement