/********* 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 Animation" - Source Code NOT compiled for: Arduino Mega - Source Code created on: 2024-06-11 22:02:55 ********* 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 #include // https://github.com/FastLED/FastLED /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void fadeall(void); /***** DEFINITION OF SPI PINS *****/ const uint8_t led_P9813_SPI_PIN_MOSI_D51 = 51; const uint8_t led_P9813_SPI_PIN_MISO_D50 = 50; const uint8_t led_P9813_SPI_PIN_SCLK_D52 = 52; const uint8_t led_P9813_SPI_PIN_CS_D53 = 53; /****** DEFINITION OF LED STRIP PARAMETERS *****/ #define NUM_LEDS 64 #define DATA_PIN 2 #define CLOCK_PIN 13 /****** DEFINITION OF LED ARRAY *****/ CRGB leds[NUM_LEDS]; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // FastLED instance is globally available as FastLED void setup(void) { // Set the data pin as output pinMode(DATA_PIN, OUTPUT); // Initialize the SPI library SPI.begin(); // Initialize the FastLED library FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(84); // Set brightness level } void loop(void) { // Implement the supercar effect 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 fadeall() { for (int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } } /* END CODE */