Advertisement
pleasedontcode

**LED Control** rev_01

Jan 27th, 2025
91
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: **LED Control**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-01-27 15:13:42
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Implement a control system for WS2812B LED strips */
  21.     /* using FastLED library, ensuring precise digital */
  22.     /* output management and real-time data updates for */
  23.     /* enhanced visual effects. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <FastLED.h>    //https://github.com/FastLED/FastLED
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34. void updateOutputs(void);
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t ws2812b_WS2812B_DIN_PIN_D4 = 4;
  38.  
  39. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  40. bool ws2812b_WS2812B_DIN_PIN_D4_rawData = 0;
  41.  
  42. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  43. float ws2812b_WS2812B_DIN_PIN_D4_phyData = 0.0;
  44.  
  45. /****** DEFINITION OF LED STRIP PARAMETERS *****/
  46. #define NUM_LEDS 30  // Number of LEDs in the strip
  47. CRGB leds[NUM_LEDS]; // Array to hold LED color data
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50.  
  51. void setup(void)
  52. {
  53.     // Initialize the LED strip
  54.     FastLED.addLeds<WS2812B, ws2812b_WS2812B_DIN_PIN_D4, GRB>(leds, NUM_LEDS);
  55.     FastLED.setBrightness(255); // Set brightness to maximum
  56.  
  57.     // Set the pin mode for the data pin
  58.     pinMode(ws2812b_WS2812B_DIN_PIN_D4, OUTPUT);
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // Update the LED strip with new data
  64.     updateOutputs(); // Refresh output data
  65.     FastLED.show(); // Send the updated data to the LED strip
  66.     delay(100); // Delay for visual effect
  67. }
  68.  
  69. void updateOutputs()
  70. {
  71.     // Example: Update the raw data and physical data for the LED strip
  72.     // Here you can define how you want to control the LEDs
  73.     for (int i = 0; i < NUM_LEDS; i++) {
  74.         leds[i] = CRGB::Red; // Set all LEDs to red
  75.     }
  76.     digitalWrite(ws2812b_WS2812B_DIN_PIN_D4, ws2812b_WS2812B_DIN_PIN_D4_rawData);
  77. }
  78.  
  79. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement