Wefix & DollyQueen
Hey Dolly, I’ve been fiddling with motion sensors and RGB LED strips—thought we could turn a floor into a live light‑show that syncs with your choreography. Imagine the beats literally glowing as you move—what’s your take on building that?
Oh honey, that’s pure fire! Picture this: every step is a spotlight, every beat a pulse of neon—my feet will paint the floor like a living, breathing score. Let’s crank up the sensors, sync the LEDs to the rhythm, and turn that room into a disco runway for the soul. Bring the code, I’ll bring the choreography, and together we’ll make the floor sing!
Cool! I’ll sketch out a quick ESP32 sketch that reads an IR proximity sensor (or a simple optical encoder on the floor) and drives an WS2812B LED strip. The idea is to push the LED brightness up whenever the sensor detects a footfall and let the strip fade back down, synced to a simple beat‑detecting tone. Here’s the core of it:
```cpp
#include <FastLED.h>
#define LED_PIN 5 // GPIO for the LED strip
#define NUM_LEDS 60 // number of LEDs (adjust for your strip length)
#define BRIGHTNESS 128
#define IR_PIN 34 // GPIO connected to your IR sensor output
CRGB leds[NUM_LEDS];
int lastPulse = 0;
int pulseDelay = 250; // how long the pulse stays bright (ms)
void setup() {
Serial.begin(115200);
pinMode(IR_PIN, INPUT_PULLUP); // IR sensor usually outputs LOW when a foot is close
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
}
void loop() {
bool footDetected = !digitalRead(IR_PIN); // LOW means a foot is detected
if (footDetected) {
lastPulse = millis(); // reset pulse timer
setPulse(255); // maximum brightness on detection
} else {
// fade out gradually if not pulsing
fadeOut();
}
// Simple beat‑sync: toggle every 500 ms (you can adjust or replace with an audio input)
static unsigned long lastBeat = 0;
if (millis() - lastBeat > 500) {
lastBeat = millis();
beatPulse();
}
FastLED.show();
delay(20); // small delay to keep loop snappy
}
void setPulse(byte brightness) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(0, 0, brightness); // white pulse, change hue if you want color
}
}
void fadeOut() {
static byte currentBrightness = 255;
if (millis() - lastPulse > pulseDelay) {
if (currentBrightness > 0) {
currentBrightness = max(0, currentBrightness - 10);
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(0, 0, currentBrightness);
}
}
}
}
void beatPulse() {
// simple beat effect: a quick flash on every beat
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(0, 0, 255); // bright flash
}
FastLED.show();
delay(30); // brief flash
fadeOut(); // let it fade back
}
```
### What it does
- **Footfall detection**: When the IR sensor goes LOW (foot over it), the strip goes to full brightness.
- **Pulse decay**: If the sensor stays idle, the LEDs gradually dim.
- **Beat sync**: Every half‑second a quick white flash mimics a beat. You can replace that part with a real audio‑to‑beat module or a microphone input if you want tighter sync.
### Things to tweak
- **Sensor**: If you have a pressure mat or a magnetic reed switch, just change `IR_PIN` logic.
- **Strip length**: Adjust `NUM_LEDS` to match your strip.
- **Hue**: Change `CHSV(0,0,brightness)` to something like `CHSV(160,255,brightness)` for blue, etc.
- **Beat source**: Swap the hard‑coded 500 ms beat interval with a real beat detector for a true dance‑floor vibe.
Upload this to your ESP32, wire the LED strip to pin 5, connect the IR sensor to pin 34, and you’ll see the floor light up in sync with your moves. Let me know how the choreography feels—happy to tweak the timing or color palette if you need!
Nice! I love the quick‑pulse idea—makes every step feel like a spotlight. Just a few tweaks to crank the vibe: swap the static 500 ms beat for a real audio‑to‑beat module or a microphone so the flash follows the rhythm, color‑shift the CHSV hue for a rainbow trail, and maybe ramp the fade speed when the foot’s off to keep the groove smooth. Wire it up, hit run, and let the floor glow with your choreography—let’s make the whole space a living, breathing stage!
Here’s a quick revamp that pulls beats from a tiny mic and spins the hue like a rainbow. I’ve also eased the fade‑out so the groove stays silky when the foot lifts.
```
#include <FastLED.h>
#include <Audio.h> // Arduino audio library
#define LED_PIN 5
#define NUM_LEDS 60
#define BRIGHTNESS 200
#define IR_PIN 34
#define MIC_PIN 36 // ESP32 ADC pin
CRGB leds[NUM_LEDS];
AudioInputAnalog mic(MIC_PIN);
int lastBeat = 0;
int beatInterval = 200; // placeholder, will be set by beat detection
void setup() {
Serial.begin(115200);
pinMode(IR_PIN, INPUT_PULLUP);
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
}
void loop() {
// 1. Beat detection from mic
float sample = mic.read(); // simple amplitude read
if (sample > 0.5) { // crude threshold
lastBeat = millis();
}
beatInterval = constrain(millis() - lastBeat, 100, 400); // keep within sane range
// 2. Footfall detection
bool footDetected = !digitalRead(IR_PIN);
if (footDetected) {
setPulse(255, random8()); // full brightness, random hue for rainbow
} else {
fadeOut(); // smooth fade
}
// 3. Beat pulse
if (millis() - lastBeat < beatInterval / 4) {
beatPulse();
}
FastLED.show();
delay(20);
}
void setPulse(byte brightness, byte hue) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue, 255, brightness);
}
}
void fadeOut() {
static byte currentHue = 0;
static byte currentBrightness = 255;
if (currentBrightness > 10) {
currentBrightness = max(0, currentBrightness - 4); // slower fade
currentHue = (currentHue + 1) % 256; // subtle hue shift
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(currentHue, 255, currentBrightness);
}
}
}
void beatPulse() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(random8(), 255, 255); // bright flash, random hue
}
}
```
Wire the mic to a low‑noise 3.3 V input, the IR sensor as before, and hit “Upload.” The strip should now flash to the beat, paint your steps with a rainbow trail, and fade smoothly when you step off. Have a blast turning that room into a living stage!
That’s the groove I love—real beats, rainbow waves, smooth fade‑out. Just a quick thought: maybe add a tiny low‑pass filter on the mic input so the threshold isn’t tripped by a quick crack, and tweak the beatInterval to lock in with the beat you actually hear. Also, if the LEDs start looking too bright at 200, you can dial back the brightness when the foot isn’t on the sensor. Once you test it, let the floor dance with your moves—time to hit the stage!
Here’s a tweak that keeps the mic clean and the LEDs in tune with the groove.
I added a simple RC low‑pass filter on the ADC reading and let the LED brightness fall back when the foot lifts.
```
#include <FastLED.h>
#include <Audio.h>
#define LED_PIN 5
#define NUM_LEDS 60
#define IR_PIN 34
#define MIC_PIN 36
CRGB leds[NUM_LEDS];
AudioInputAnalog mic(MIC_PIN);
int lastBeat = 0;
int beatInterval = 200;
float filtered = 0;
const float RC = 0.05; // low‑pass coefficient (adjust for smoother response)
void setup() {
pinMode(IR_PIN, INPUT_PULLUP);
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(150); // start with a moderate base brightness
}
void loop() {
// 1. Low‑pass filter the raw mic sample
float raw = mic.read();
filtered += (raw - filtered) * RC;
// 2. Beat detection on the filtered value
if (filtered > 0.4) { // threshold tuned for filtered signal
lastBeat = millis();
}
beatInterval = constrain(millis() - lastBeat, 100, 400);
// 3. Footfall detection
bool footDetected = !digitalRead(IR_PIN);
if (footDetected) {
setPulse(255, random8()); // bright, rainbow hue
} else {
fadeOut(); // smooth fade and lower brightness
}
// 4. Beat pulse
if (millis() - lastBeat < beatInterval / 4) {
beatPulse();
}
FastLED.show();
delay(20);
}
void setPulse(byte brightness, byte hue) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue, 255, brightness);
}
}
void fadeOut() {
static byte currentHue = 0;
static byte currentBrightness = 255;
if (currentBrightness > 10) {
currentBrightness = max(0, currentBrightness - 4); // slower fade
currentHue = (currentHue + 1) % 256; // subtle hue shift
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(currentHue, 255, currentBrightness);
}
// Dim the overall strip when foot is off
FastLED.setBrightness(map(currentBrightness, 0, 255, 50, 150));
}
}
void beatPulse() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(random8(), 255, 255);
}
}
```
Upload that, hit the floor, and you’ll get a cleaner beat sync, rainbow waves, and a smoother fade‑out that respects the real rhythm. Enjoy turning the room into a live stage!