Advertisement
pleasedontcode

RGB LED Fader rev_08

May 4th, 2024
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: RGB LED Fader
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-04 09:18:13
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* output d5  number of led 20  ws2812B RGB  use */
  21.     /* random color  fade in and out in 10 seconds */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <FastLED.h>    //https://github.com/FastLED/FastLED
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30. void updateOutputs(void);
  31.  
  32. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  33. const uint8_t LEDBoard_LEDRGB_Red_PIN_D5    = 5; // Output pin for WS2812B RGB LED strip
  34. #define NUM_LEDS 20 // Number of LEDs in the strip
  35.  
  36. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  37. /***** used to store raw data *****/
  38. bool    LEDBoard_LEDRGB_Red_PIN_D5_rawData = 0;
  39.  
  40. // Define LED strip parameters
  41. #define DATA_PIN 6
  42. #define LED_TYPE WS2812B
  43. #define COLOR_ORDER GRB
  44.  
  45. CRGB leds[NUM_LEDS];
  46.  
  47. void setup(void)
  48. {
  49.     // put your setup code here, to run once:
  50.  
  51.     FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  52.     pinMode(LEDBoard_LEDRGB_Red_PIN_D5, OUTPUT);
  53.  
  54. }
  55.  
  56. void loop(void)
  57. {
  58.     // put your main code here, to run repeatedly:
  59.  
  60.     // Random color fade in and out in 10 seconds
  61.     uint8_t brightness = beatsin8(60, 0, 255);
  62.     uint8_t hue = beatsin8(40, 0, 255);
  63.     fill_solid(leds, NUM_LEDS, CHSV(hue, 255, brightness));
  64.     FastLED.show();
  65.     delay(100); // Adjust the delay time for fade effect
  66.  
  67. }
  68.  
  69. void updateOutputs()
  70. {
  71.     digitalWrite(LEDBoard_LEDRGB_Red_PIN_D5, LEDBoard_LEDRGB_Red_PIN_D5_rawData);
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement