Advertisement
pleasedontcode

Colorful Control rev_07

May 1st, 2024
179
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: Colorful Control
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-01 10:45:04
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* chipset WS2812B RGB  Number of LED 20  Output D5 */
  21.     /* fade in and out from 0 to 255  color random    set */
  22.     /* fade out value at 255  use all colors randomly for */
  23.     /* each led and */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <FastLED.h>    //https://github.com/FastLED/FastLED
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void updateOutputs(void); // Added function prototype for updateOutputs
  33.  
  34. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  35. const uint8_t WS2812B_LEDRGB_PIN_D5 = 5; // Define the output pin for WS2812B LED
  36.  
  37. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  38. /***** used to store raw data *****/
  39. bool WS2812B_LEDRGB_PIN_D5_rawData = 0;
  40.  
  41. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  42. /***** used to store data after characteristic curve transformation *****/
  43. float WS2812B_LEDRGB_PIN_D5_phyData = 0.0;
  44.  
  45. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  46. CRGB leds[20]; // Define the LED array based on the number of LEDs
  47.  
  48. void setup(void)
  49. {
  50.     // put your setup code here, to run once:
  51.  
  52.     pinMode(WS2812B_LEDRGB_PIN_D5, OUTPUT);
  53.  
  54.     FastLED.addLeds<WS2812B, WS2812B_LEDRGB_PIN_D5, GRB>(leds, 20); // Initialize FastLED object with LED array and pin configuration
  55.  
  56. }
  57.  
  58.  
  59. void loop(void)
  60. {
  61.     // put your main code here, to run repeatedly:
  62.  
  63.     updateOutputs(); // Refresh output data
  64.  
  65. }
  66.  
  67. void updateOutputs()
  68. {
  69.     // Fade in and out from 0 to 255 with random colors for each LED
  70.     for (int i = 0; i < 20; i++) {
  71.         leds[i] = CHSV(random8(), 255, 255); // Set random hue, full saturation, and full value (brightness)
  72.     }
  73.  
  74.     FastLED.show(); // Show the updated LED colors
  75. }
  76.  
  77. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement