Advertisement
pleasedontcode

"Fade Brightness" rev_03

Jul 9th, 2024
156
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: "Fade Brightness"
  13.     - Source Code NOT compiled for: Arduino Nano
  14.     - Source Code created on: 2024-07-09 19:05:12
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* fade red flashing */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* Create a pulsing red light effect on the WS2812B */
  23.     /* LED strip connected to pin D2, utilizing the */
  24.     /* FastLED library for smooth transitions. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <FastLED.h>    //https://github.com/FastLED/FastLED
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33. void updateOutputs(void);
  34.  
  35. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  36. const uint8_t DATA_PIN = 2;
  37.  
  38. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  39. /***** used to store raw data *****/
  40. bool WS2812B_WS2812B_DIN_PIN_D2_rawData = 0;
  41.  
  42. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  43. /***** used to store data after characteristic curve transformation *****/
  44. float WS2812B_WS2812B_DIN_PIN_D2_phyData = 0.0;
  45.  
  46. /****** DEFINITION OF LED STRIP PARAMETERS *****/
  47. #define NUM_LEDS 60
  48.  
  49. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  50. CRGB leds[NUM_LEDS]; // Array of LEDs
  51.  
  52. void setup(void)
  53. {
  54.     // put your setup code here, to run once:
  55.     pinMode(DATA_PIN, OUTPUT);
  56.  
  57.     // Initialize the LED strip
  58.     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // put your main code here, to run repeatedly:
  64.     updateOutputs(); // Refresh output data
  65.  
  66.     // Fade red flashing effect
  67.     for (int brightness = 0; brightness < 255; brightness++) {
  68.         fill_solid(leds, NUM_LEDS, CRGB(brightness, 0, 0));
  69.         FastLED.show();
  70.         delay(10);
  71.     }
  72.     for (int brightness = 255; brightness >= 0; brightness--) {
  73.         fill_solid(leds, NUM_LEDS, CRGB(brightness, 0, 0));
  74.         FastLED.show();
  75.         delay(10);
  76.     }
  77. }
  78.  
  79. void updateOutputs()
  80. {
  81.     digitalWrite(DATA_PIN, WS2812B_WS2812B_DIN_PIN_D2_rawData);
  82. }
  83.  
  84. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement