// https://forum.arduino.cc/t/fastled-only-works-when-serial-monitor-is-open-esp32-c3-mini/1463075/36
// until FastLED 3.10.7 is fixed, look at "libraries.txt" and read this:
// https://docs.wokwi.com/guides/libraries#the-librariestxt-file
#include <FastLED.h>
#define NUM_LEDS 358
#define DATA_PIN 0
CRGB leds[NUM_LEDS]; // Fast LED OBJECT
// 0 + 42 + 25 + 42 + 25 ... + 69 + 43 + 69 + 43 = 358 [0, 357]
#define Wall_Long 42 // number
#define Wall_Short 25
int Wall_Top = 0 + Wall_Long; // 0 + 42 = [0, 41]
int Wall_Right = Wall_Top + Wall_Short; // 42 + 25 = 67 [42, 66]
int Wall_Bottom = Wall_Right + Wall_Long; // 67 + 42 = 109 [67, 108]
int Wall_Left = Wall_Bottom + Wall_Short; // 109 + 25 = 134 [109, 133]
#define Display_Long 69
#define Display_Short 43
int Display_Top = Wall_Left + Display_Long; // continuing from "Wall_Left" 134 + 69 = 203 [134, 202]
int Display_Right = Display_Top + Display_Short; // 202 + 43 = 246 [202, 245]
int Display_Bottom = Display_Right + Display_Long; //253 + 43 = 315 [253, 314]
int Display_Left = Display_Bottom + Display_Short; // 296 + 69 = 358 [296, 357]
#define SingleLED 2
byte buttonPin3 = 3;
byte buttonPin4 = 4;
unsigned long timer, timeout = 1000;
bool toggle = 0;
void setup() {
Serial.begin(115200);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
// startup(); // show sequence of all LEDs.
}
void loop() {
if (digitalRead(buttonPin3))
displayWall();
if (digitalRead(buttonPin4))
displayDisplay();
FastLED.clear();
FastLED.show();
}
void startup() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Lime;
FastLED.show();
delay(1);
FastLED.clear();
}
}
void displayWall() {
int val = 255;
fill_solid(leds + 0, Wall_Long, CRGB(val, 0, 0)); // array start, number of pix, color
fill_solid(leds + Wall_Top, Wall_Short, CRGB(val, 0, 0));
fill_solid(leds + Wall_Right, Wall_Long, CRGB(val, 0, 0));
fill_solid(leds + Wall_Bottom, Wall_Short, CRGB(val, 0, 0));
FastLED.show();
}
void displayDisplay() {
int val = 255;
fill_solid(leds + Wall_Left, Display_Long, CRGB(0, 0, val)); // array start, number of pix, color
fill_solid(leds + Display_Top, Display_Short, CRGB(0, 0, val));
fill_solid(leds + Display_Right, Display_Long, CRGB(0, 0, val));
fill_solid(leds + Display_Bottom, Display_Short, CRGB(0, 0, val));
FastLED.show();
}Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1
Wait for the GREEN LED to light all the LEDs
then press the LEFT or RIGHT button