Advertisement
safwan092

WS2812

Nov 24th, 2021
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. int r = 0;
  4. int g = 0;
  5. int b = 0;
  6.  
  7. #define LED_PIN     5
  8. #define NUM_LEDS    16
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12. void setup() {
  13.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  14. }
  15. void loop()
  16. {
  17.   c1();
  18.   c2();
  19. }
  20.  
  21.  
  22. void c1() {//White
  23.   for (int i = 0; i < NUM_LEDS; i++)
  24.   {
  25.     leds[i] = CRGB (100, 100, 100);
  26.   }
  27.   FastLED.show();
  28.   delay(1000);
  29. }
  30. void c2() {//Red
  31.   for (int i = 0; i < NUM_LEDS; i++)
  32.   {
  33.     leds[i] = CRGB (255, 0, 0);
  34.   }
  35.   FastLED.show();
  36.   delay(1000);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement