Advertisement
uwezi

20210113_arduino_neopixel

Jan 13th, 2021
1,333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Arduino.h>
  2. #include <FastLED.h>
  3.  
  4. #define LED_PIN     11
  5. #define COLOR_ORDER GRB
  6. #define CHIPSET     WS2811
  7. #define NUM_LEDS    1
  8.  
  9. CRGB leds[NUM_LEDS];
  10.  
  11. void setup()
  12. {
  13.   FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  14. }
  15.  
  16. uint8_t i=0;
  17. uint8_t upp=1;
  18. void loop()
  19. {
  20.   if (upp)
  21.   {
  22.     if (i<255)
  23.     {
  24.       i++;
  25.     }
  26.     else
  27.     {
  28.       upp = 0;
  29.     }
  30.   }
  31.   else
  32.   {
  33.     if (i>0)
  34.     {
  35.       i--;
  36.     }
  37.     else
  38.     {
  39.       upp = 1;
  40.     }
  41.   }
  42.  
  43.   leds[0].r = i;
  44.   leds[0].g = i;
  45.   leds[0].b = i;
  46.   FastLED.show();
  47.   delay(4);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement