Advertisement
safwan092

Untitled

Feb 11th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define LED_PIN 5 // Pin number connected to the LED strip
  4. #define NUM_LEDS 60 // Number of LEDs in the strip
  5. #define LED_TYPE WS2812B // Type of the LED strip
  6. #define COLOR_ORDER GRB // Color order of the LED strip
  7.  
  8. CRGB leds[NUM_LEDS]; // Define an array of CRGB objects representing each LED
  9.  
  10. void setup() {
  11. FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); // Initialize the LED strip
  12. }
  13.  
  14. void loop() {
  15. // Set your custom RGB values here (from 0 to 255 for each color)
  16. uint8_t r = 255; // Red value
  17. uint8_t g = 0; // Green value
  18. uint8_t b = 255; // Blue value
  19.  
  20. // Set all LEDs to the custom color
  21. fill_solid(leds, NUM_LEDS, CRGB(r, g, b));
  22.  
  23. // Show the updated LEDs
  24. FastLED.show();
  25.  
  26. // Add a delay to control the speed of color changes
  27. delay(1000); // 1000 milliseconds = 1 second
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement