XIAO ESP32-c3 push buttons and pins connections issue

Hi there,

Ok, So it is slightly different as we suspected. for example the LED is connected to GPIO8 , that is different than the Xiao.

Yes, you are correct. The polling will use more Power over all, its always on and running, Done with interrupts you can use SLEEP to save a ton of power and get great battery life.

There is FORsure some examples of this configuration and Tech.

There is actually a BLE demo (albeit Nrf based , Kitchen Sink) on here , with Wakeup and Sleep and tap detection to increment a counter.
Just scan the code to see where you go on certain logic’s

The BASIC’s…
Switch Debouncing – Quick Explanation:

When a mechanical switch (like a button) is pressed or released, the contacts don’t close cleanly — they bounce, causing multiple rapid on/off signals within a few milliseconds. This can cause a microcontroller to detect multiple presses from a single tap.

Debouncing is the process of ignoring those rapid false transitions by:

  • Waiting a short time (e.g. 20–50 ms) after a change is detected
  • Only accepting new input if the state remains stable

Software Example:

if (digitalRead(BUTTON_PIN) != lastButtonState) {
  lastDebounceTime = millis();  // Reset timer on change
}

if ((millis() - lastDebounceTime) > debounceDelay) {
  if (digitalRead(BUTTON_PIN) == LOW) {
    // Button is stable and pressed
  }
}

lastButtonState = digitalRead(BUTTON_PIN);

the software debounce is really all that is needed , However there is a hardware version using a Capacitor + resistor.
:+1:

Have you looked at the WiKi for the C3 it’s good to look those over for the MCU lots of very good info there to get You started.

Your end goal description is good and is doable and AFAIK there is a example of it here somewhere :grin: I look a little more when I get home later…

HTH
GL :slight_smile: PJ :v: