Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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: "FastLED Control" - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-07-03 20:21:27 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* "Convert the glediator code for ESP32 so that I */ /* can control my LED strip with the RemoteLight app */ /* via USB connection on a PC." */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
//https://github.com/FastLED/FastLED /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); void readSerialData(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t Ledstrip_WS2812_DIN_PIN_D4 = 4; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool Ledstrip_WS2812_DIN_PIN_D4_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float Ledstrip_WS2812_DIN_PIN_D4_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ #define NUM_LEDS 60 #define DATA_PIN 4 CRGB leds[NUM_LEDS]; void setup(void) { // Initialize serial communication at 115200 baud rate Serial.begin(115200); // Initialize the FastLED library FastLED.addLeds
(leds, NUM_LEDS); FastLED.setBrightness(50); // Set brightness to 50 out of 255 } void loop(void) { // Read data from serial readSerialData(); // Refresh output data updateOutputs(); // Show the LED data FastLED.show(); } void updateOutputs() { digitalWrite(Ledstrip_WS2812_DIN_PIN_D4, Ledstrip_WS2812_DIN_PIN_D4_rawData); } void readSerialData() { static uint16_t dataIndex = 0; static uint8_t buffer[NUM_LEDS * 3]; // Buffer to store incoming data while (Serial.available()) { buffer[dataIndex++] = Serial.read(); // If buffer is full, update LED strip if (dataIndex >= sizeof(buffer)) { for (uint16_t i = 0; i < NUM_LEDS; i++) { leds[i].r = buffer[i * 3]; leds[i].g = buffer[i * 3 + 1]; leds[i].b = buffer[i * 3 + 2]; } dataIndex = 0; // Reset index for next frame } } } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)