/********* 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: FastLED Control - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-05-04 09:30:50 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* output d5 number of led 20 ws2812B RGB use */ /* random color fade in and out in 10 seconds */ /****** SYSTEM REQUIREMENT 2 *****/ /* output d5 ws2812B number of LED 20 each LED */ /* random color use 256 colors each LED random */ /* brightness from 0 to 255 each LED fading in and */ /* out random speed */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include // https://github.com/FastLED/FastLED /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); void randomFadeInOut(void); void randomFadingLEDs(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t LED_PIN_D5 = 5; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ bool LED_PIN_D5_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ float LED_PIN_D5_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ #define NUM_LEDS 20 #define DATA_PIN 5 #define BRIGHTNESS 50 CRGB leds[NUM_LEDS]; FastLED_NeoPixel_Variant strip(leds, NUM_LEDS); void setup(void) { // put your setup code here, to run once: pinMode(LED_PIN_D5, OUTPUT); strip.begin(FastLED.addLeds(leds, NUM_LEDS)); strip.setBrightness(BRIGHTNESS); } void loop(void) { // put your main code here, to run repeatedly: randomFadeInOut(); // System Requirement 1 randomFadingLEDs(); // System Requirement 2 updateOutputs(); // Refresh output data } void updateOutputs(void) { digitalWrite(LED_PIN_D5, LED_PIN_D5_rawData); } void randomFadeInOut(void) { // Random color fade in and out in 10 seconds for LED connected to D5 // Implement the code for System Requirement 1 here for (int i = 0; i < 256; i++) { uint8_t brightness = i; leds[0] = CHSV(random8(), 255, brightness); FastLED.show(); delay(40); } for (int i = 255; i >= 0; i--) { uint8_t brightness = i; leds[0] = CHSV(random8(), 255, brightness); FastLED.show(); delay(40); } } void randomFadingLEDs(void) { // Random color, brightness, and fading in and out for each LED connected to D5 // Implement the code for System Requirement 2 here for (int i = 0; i < NUM_LEDS; i++) { uint8_t brightness = random8(); leds[i] = CHSV(random8(), 255, brightness); } FastLED.show(); delay(random(100, 1000)); }