Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "Supercar Illumination"
- - Source Code NOT compiled for: Arduino Mega
- - Source Code created on: 2024-06-11 22:00:39
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Implement a supercar effect using LED strip */
- /* controlled by FastLED library. The setup involves */
- /* initializing digital pin 2 for output and */
- /* continuously updating the LED state based on raw */
- /* data input. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <FastLED.h> //https://github.com/FastLED/FastLED
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- void fadeall(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t strip_TM1809_DIN_PIN_D3 = 3;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool strip_TM1809_DIN_PIN_D3_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float strip_TM1809_DIN_PIN_D3_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Number of LEDs in the strip
- #define NUM_LEDS 64
- // Define the array of LEDs
- CRGB leds[NUM_LEDS];
- // Initialize the FastLED object
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(strip_TM1809_DIN_PIN_D3, OUTPUT);
- // Initialize the FastLED library
- FastLED.addLeds<TM1809, strip_TM1809_DIN_PIN_D3, RGB>(leds, NUM_LEDS);
- FastLED.setBrightness(84); // Set the brightness to a moderate level
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- // Supercar effect using LED strip
- static uint8_t hue = 0;
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(hue++, 255, 255);
- FastLED.show();
- fadeall();
- delay(10);
- }
- for (int i = NUM_LEDS - 1; i >= 0; i--) {
- leds[i] = CHSV(hue++, 255, 255);
- FastLED.show();
- fadeall();
- delay(10);
- }
- }
- void updateOutputs()
- {
- digitalWrite(strip_TM1809_DIN_PIN_D3, strip_TM1809_DIN_PIN_D3_rawData);
- }
- // Function to gradually reduce the brightness of all LEDs
- void fadeall() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].nscale8(250);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement