classicsat

LED strip group

Jan 11th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // LED strip group
  2.  
  3. #include "FastLED.h"
  4. #define NUM_LEDS 39 // Number of LEDs
  5. #define COLOR_ORDER RGB // Define color order for your strip
  6. #define DATA_PIN 6 // Data pin for led comunication
  7.  
  8.  
  9.  
  10. CRGB leds[NUM_LEDS]; // Define LEDs strip
  11.  
  12. uint32_t ledColor = 0x0FF000; // Color used (in hex)
  13. uint32_t ledOff = 0x000000; // LED "off" color used (in hex)
  14.  
  15.  
  16. void setup() {
  17.  
  18. LEDS.addLeds<WS2812, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // Set LED strip type
  19. LEDS.setBrightness(64); // Set initial brightness
  20.  
  21. }
  22.  
  23. void loop(){
  24.  
  25. // One at a time
  26. for (byte b=0;b<9;b++){
  27.  
  28. //set LEDs
  29. groupout(b,ledColor);
  30.  
  31. FastLED.show(); // Display leds array
  32. delay(800);// wait a bit
  33.  
  34. // blank the same ones
  35. groupout(b,ledOff);
  36. }
  37.  
  38. // all on
  39. for (byte b=0;b<9;b++){
  40. groupout(b,ledColor);
  41. }
  42. FastLED.show(); // Display leds array
  43. delay(800);// you get the drill
  44.  
  45. for (byte b=0;b<9;b++){
  46. groupout(b,ledOff);
  47. }
  48.  
  49. }
  50.  
  51. // set group of 4 LEDs
  52. void groupout(byte position,uint32_t color) {
  53.  
  54. for (byte i = 0; i < 4; i++) {
  55. leds[(4*position)+i] = color;
  56. }// close for i loop
  57. }
Advertisement
Add Comment
Please, Sign In to add comment