Seeed XIAO SAMD21 · xiao-safe-gpio

Use XIAO inputs and outputs safely

Question: What is the most important electrical limit to remember when wiring XIAO GPIO?

Understand the idea

The XIAO SAMD21 uses 3.3 V logic. Its general-purpose pins are not 5 V tolerant: a signal above the permitted input voltage can damage the microcontroller. A module that can only output 5 V needs a suitable level shifter or a different interface before it reaches a GPIO pin.

A GPIO output is a logic signal, not a general-purpose power supply. For an LED, include a series resistor and calculate its approximate current from the supply voltage, LED forward voltage, and resistor value. Motors, relays, and other high-current loads need a correctly rated driver and their own power path.

A button can use `INPUT_PULLUP`: wire the switch between the input and ground, then interpret LOW as pressed. This uses the board's internal pull-up and avoids leaving the input floating. Disconnect USB and external power before moving wires.

Worked example

With 3.3 V, a red LED estimated at 2.0 V, and a 330 Ω resistor, the simple current estimate is (3.3 − 2.0) / 330 ≈ 3.9 mA. Check the LED and board ratings; this calculation is an estimate, not a guarantee of brightness.

Try it at the bench

  1. With power disconnected, wire one LED in series with a resistor between a GPIO pin and ground; confirm polarity and the board's pinout.
  2. Upload a slow blink sketch and observe the LED. Then change the interval and explain which line controls timing.
  3. Wire a pushbutton from a second GPIO to ground, configure `INPUT_PULLUP`, and print PRESSED only when the input reads LOW. Never apply a 5 V signal to a XIAO GPIO.

Check your understanding

Why does the button read LOW when pressed with `INPUT_PULLUP`?

Show the answer

The internal resistor holds the pin HIGH while the switch is open; pressing connects the pin to ground, which is LOW.

Browse all course lessons