Overriding parts of the strip depending on GPIO

Hey there, i added some WS2811 strips to my bedframe. They have been working perfectly fine for a longer time now, however i got an idea:

I have four drawers under my bed. I am thinking about putting switches next to each drawer which switch whenever the drawer is opened or closed. The plan is that the segment of LEDs above an opened drawer goes to solid white, while all other parts of the strip continue as usual.

So the question is: how do I override a segment of the strip while the rest remains as-is?

I would be happy to receive some inspiration,
Thanks :slight_smile:

Use API presets.

That sounds like a great idea for your bedframe! To achieve the effect of overriding a segment of your WS2811 strip when a drawer is opened, you can follow these steps:

1. Segment Configuration

  • Define Segments: In WLED, you can configure segments in the app. Set up a segment for each drawer. For example, if you have four drawers, create four segments corresponding to the LED sections above each drawer.

2. Use GPIO Switches

  • Switch Setup: Connect a physical switch (like a limit switch) next to each drawer to a GPIO pin on your ESP32/ESP8266. When the drawer is opened, the switch will be activated, sending a signal to your microcontroller.

3. Modify Behavior with Code

  • Event Handling: Write code that listens for the state changes of the GPIO pins. When a switch is activated, you can set the corresponding segment to solid white:
    if (drawer1SwitchState == HIGH) {
        // Set segment 1 to white
        setSegmentColor(0, 255, 255, 255); // RGB values for white
    } else {
        // Restore original effect for segment 1
        restoreSegment(0);
    }
    

4. Keep Other Segments Active

  • Ensure that your code only modifies the state of the affected segment while leaving the other segments and their effects unchanged.

5. Test and Adjust

  • Once implemented, test the setup to ensure the segments respond correctly to the drawer switches. Make adjustments to the timings and effects as needed.

6. Use WLED Effects

  • If you’re using WLED’s built-in effects, you can programmatically set the active effect for the segment that corresponds to the open drawer while keeping the others running their original effects.https://www.oemstron.com/

This setup should give you the functionality you’re looking for. If you have further questions about coding or hardware setup, feel free to ask!