/********* 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-01 09:51:01
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* The LED chipset is WS2812B RGB Number of LED is */
/* 20 Digital output is D5 all 20 led fade in and */
/* out slowly and randomly. set fade in value at 0, */
/* set fade out value at 255 use all colors randomly */
/* for each led and */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/FastLED/FastLED
const uint8_t NUM_LEDS = 20; // Number of WS2812B RGB LEDs
const uint8_t WS2812B_LEDRGB_PIN = 5; // Digital output pin for WS2812B LEDs
CRGB leds[NUM_LEDS]; // Define the LED array
void setup(void)
{
// put your setup code here, to run once:
FastLED.addLeds(leds, NUM_LEDS);
}
void loop(void)
{
// put your main code here, to run repeatedly:
fadeInOutRandomColors();
}
void fadeInOutRandomColors()
{
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(0, 0, 0); // Initialize LED color to off
}
while (true) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i].fadeToBlackBy(5); // Fade out LED color
}
int ledIndex = random8(NUM_LEDS); // Select a random LED
leds[ledIndex] = CRGB(random8(), random8(), random8()); // Set random color to the selected LED
leds[ledIndex].fadeToBlackBy(-5); // Fade in LED color
FastLED.show();
delay(50); // Adjust the delay time for fade effect
}
}
/* END CODE */