Skip to content

Instantly share code, notes, and snippets.

@katsuyoshi
Created February 18, 2023 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsuyoshi/41a3b3bfd8dfa2d24c095900259329e1 to your computer and use it in GitHub Desktop.
Save katsuyoshi/41a3b3bfd8dfa2d24c095900259329e1 to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#include <FastLED.h>
#define LED_PIN 21
#define NUM_LEDS 1
static CRGB leds[NUM_LEDS];
void setLed(CRGB color) {
// change RGB to GRB
uint8_t t = color.r;
color.r = color.g;
color.g = t;
leds[0] = color;
FastLED.show();
}
void setup() {
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(255 * 15 / 100);
}
void loop() {
setLed(CRGB::Red);
delay(1000);
setLed(CRGB::Green);
delay(1000);
setLed(CRGB::Blue);
delay(1000);
setLed(CRGB::Black);
delay(1000);
}
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
build_flags =
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
monitor_speed = 115200
lib_deps = fastled/FastLED@^3.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment