/********* 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: Warm Glow - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-05-01 09:31:48 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* The LED chipset is WS2812B RGB Number of LED is */ /* 20 Digital output is D5 write a code: led fade */ /* in and out randomly, increments 5. set fade in */ /* value at 0, set fade out value at 255 set fade */ /* time from 0 to 255 at 5 seconds use only warm */ /* colors */ /****** END SYSTEM REQUIREMENTS *****/ /********* User code review feedback ********** #### Feedback 1 #### - The colors for each led are random, use warm colors only #### Feedback 2 #### - the 20 led fade in and out at the same time. this should not be. each single led should fade in and out separately and randomly ********* User code review feedback **********/ /****** DEFINITION OF LIBRARIES *****/ #include //https://github.com/FastLED/FastLED /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); void ledFadeInOut(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t WS2812B_LEDRGB_PIN_D5 = 5; // Digital output pin D5 for WS2812B LED /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ CRGB leds[20]; // Define LED array with 20 LEDs void setup(void) { // put your setup code here, to run once: FastLED.addLeds(leds, 20); // Initialize FastLED object with 20 LEDs on pin D5 pinMode(WS2812B_LEDRGB_PIN_D5, OUTPUT); // Set D5 pin as output } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data ledFadeInOut(); // Perform LED fade in and out randomly } void updateOutputs() { // No need to update outputs in this case } void ledFadeInOut() { static uint8_t fadeValues[20] = {0}; // Array to store fade values for each LED static bool fadeDirections[20] = {true}; // Array to store fade directions for each LED for (int i = 0; i < 20; i++) { if (fadeDirections[i]) { fadeValues[i] += 5; if (fadeValues[i] >= 255) { fadeDirections[i] = false; } } else { fadeValues[i] -= 5; if (fadeValues[i] <= 0) { fadeDirections[i] = true; } } // Set warm color based on fade value for each LED CRGB color = CRGB(fadeValues[i], fadeValues[i] * 0.7, fadeValues[i] * 0.3); // Set LED color leds[i] = color; } // Show LED colors FastLED.show(); } /* END CODE */