Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Colorful Fading
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-05-01 10:39:48
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* chipset WS2812B RGB Number of LED 20 Output D5 */
- /* fade in and out from 0 to 255 while keeping color */
- /* set fade out value at 255 use all colors randomly */
- /* for each led and */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <FastLED.h> // https://github.com/FastLED/FastLED
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void); // Added function prototype for updateOutputs
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t WS2812B_LEDRGB_PIN_D5 = 5; // Define output pin for WS2812B LEDs
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool WS2812B_LEDRGB_PIN_D5_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float WS2812B_LEDRGB_PIN_D5_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- CRGB leds[20]; // Define CRGB array for 20 LEDs
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(WS2812B_LEDRGB_PIN_D5, OUTPUT);
- // Initialize FastLED library object
- FastLED.addLeds<WS2812B, WS2812B_LEDRGB_PIN_D5>(leds, 20);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- // Generate random color values for each LED
- for (int i = 0; i < 20; i++)
- {
- leds[i] = CHSV(random8(), 255, 255); // Random hue, full saturation and value
- }
- // Fade in and out effect
- for (int brightness = 0; brightness <= 255; brightness++)
- {
- for (int i = 0; i < 20; i++)
- {
- leds[i].fadeToBlackBy(255 - brightness); // Fade out
- leds[i].fadeToBlackBy(brightness); // Fade in
- }
- FastLED.show();
- delay(50);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement