1.10.2 Using Button Inputs to Control RGB Lights and OLED Display
This example shows how to use a button press to trigger the RGB lights and OLED display on the sheenbot∞. When Button A is pressed, a message is shown on the OLED, all three RGB lights turn on, and then switch off one by one with a delay.
Follow the logic below to understand how this interaction is structured:
- Check if Button A is pressed
- If pressed:
- Display "Button A" on the OLED
- Turn on RGB LED 0 (yellow)
- Turn on RGB LED 1 (cyan)
- Turn on RGB LED 2 (red)
- Wait 1 second, then turn off RGB LED 0
- Wait 1 second, then turn off RGB LED 1
- Wait 1 second, then turn off RGB LED 2
- Clear the OLED display line

FFigure 1.10.2a: Button A press logic with RGB and OLED
- Check if Button B is pressed
- If pressed:
- Display "Button B" on the OLED
- Turn on RGB LED 0 (green)
- Turn on RGB LED 1 (red)
- Turn on RGB LED 2 (orange)
- Keep the pattern active briefly
- Turn off all RGB LEDs
- Clear the OLED display line

Figure 1.10.2b: Button B press logic with RGB and OLED