Advertisement
pleasedontcode

"Red Fade" rev_04

Jul 9th, 2024
162
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: "Red Fade"
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2024-07-09 19:17:09
  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.  
  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 DATA_PIN = 2;
  38.  
  39. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  40. /***** used to store raw data *****/
  41. bool WS2812B_WS2812B_DIN_PIN_D2_rawData = 0;
  42.  
  43. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  44. /***** used to store data after characteristic curve transformation *****/
  45. float WS2812B_WS2812B_DIN_PIN_D2_phyData = 0.0;
  46.  
  47. /****** DEFINITION OF LED STRIP PARAMETERS *****/
  48. #define NUM_LEDS 60
  49.  
  50. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  51. CRGB leds[NUM_LEDS]; // Array of LEDs
  52.  
  53. void setup(void)
  54. {
  55.     // put your setup code here, to run once:
  56.     pinMode(DATA_PIN, OUTPUT);
  57.  
  58.     // Initialize the LED strip
  59.     FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  60. }
  61.  
  62. void loop(void)
  63. {
  64.     // put your main code here, to run repeatedly:
  65.     updateOutputs(); // Refresh output data
  66.  
  67.     // Fade red flashing effect
  68.     for (int brightness = 0; brightness < 255; brightness++) {
  69.         fill_solid(leds, NUM_LEDS, CRGB(brightness, 0, 0));
  70.         FastLED.show();
  71.         delay(10);
  72.     }
  73.     for (int brightness = 255; brightness >= 0; brightness--) {
  74.         fill_solid(leds, NUM_LEDS, CRGB(brightness, 0, 0));
  75.         FastLED.show();
  76.         delay(10);
  77.     }
  78. }
  79.  
  80. void updateOutputs()
  81. {
  82.     digitalWrite(DATA_PIN, WS2812B_WS2812B_DIN_PIN_D2_rawData);
  83. }
  84.  
  85. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement