Advertisement
pleasedontcode

"Fading Red" rev_02

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