Advertisement
pleasedontcode

"Supercar Illumination" rev_06

Jun 11th, 2024
424
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: "Supercar Illumination"
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2024-06-11 22:00:39
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Implement a supercar effect using LED strip */
  21.     /* controlled by FastLED library. The setup involves */
  22.     /* initializing digital pin 2 for output and */
  23.     /* continuously updating the LED state based on raw */
  24.     /* data input. */
  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. void fadeall(void);
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t strip_TM1809_DIN_PIN_D3 = 3;
  38.  
  39. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  40. /***** used to store raw data *****/
  41. bool strip_TM1809_DIN_PIN_D3_rawData = 0;
  42.  
  43. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  44. /***** used to store data after characteristic curve transformation *****/
  45. float strip_TM1809_DIN_PIN_D3_phyData = 0.0;
  46.  
  47. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  48.  
  49. // Number of LEDs in the strip
  50. #define NUM_LEDS 64
  51.  
  52. // Define the array of LEDs
  53. CRGB leds[NUM_LEDS];
  54.  
  55. // Initialize the FastLED object
  56. void setup(void)
  57. {
  58.     // put your setup code here, to run once:
  59.     pinMode(strip_TM1809_DIN_PIN_D3, OUTPUT);
  60.  
  61.     // Initialize the FastLED library
  62.     FastLED.addLeds<TM1809, strip_TM1809_DIN_PIN_D3, RGB>(leds, NUM_LEDS);
  63.     FastLED.setBrightness(84);  // Set the brightness to a moderate level
  64. }
  65.  
  66. void loop(void)
  67. {
  68.     // put your main code here, to run repeatedly:
  69.     updateOutputs(); // Refresh output data
  70.  
  71.     // Supercar effect using LED strip
  72.     static uint8_t hue = 0;
  73.     for (int i = 0; i < NUM_LEDS; i++) {
  74.         leds[i] = CHSV(hue++, 255, 255);
  75.         FastLED.show();
  76.         fadeall();
  77.         delay(10);
  78.     }
  79.     for (int i = NUM_LEDS - 1; i >= 0; i--) {
  80.         leds[i] = CHSV(hue++, 255, 255);
  81.         FastLED.show();
  82.         fadeall();
  83.         delay(10);
  84.     }
  85. }
  86.  
  87. void updateOutputs()
  88. {
  89.     digitalWrite(strip_TM1809_DIN_PIN_D3, strip_TM1809_DIN_PIN_D3_rawData);
  90. }
  91.  
  92. // Function to gradually reduce the brightness of all LEDs
  93. void fadeall() {
  94.     for (int i = 0; i < NUM_LEDS; i++) {
  95.         leds[i].nscale8(250);
  96.     }
  97. }
  98.  
  99. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement