// ============================================================ // Seeed XIAO SAMD21 - Tact Switch + LED // Press the button to turn on the LED // ============================================================ const int buttonPin = 1; // D1 - tact switch input pin const int ledPin = 7; // D7 - LED output pin void setup() { // Set button pin as input with internal pull-up resistor // When button is not pressed: pin reads HIGH // When button is pressed: pin reads LOW pinMode(buttonPin, INPUT_PULLUP); // Set LED pin as output pinMode(ledPin, OUTPUT); } void loop() { // Read the current state of the button int buttonState = digitalRead(buttonPin); if (buttonState == LOW) { // Button is pressed → turn LED on digitalWrite(ledPin, HIGH); } else { // Button is released → turn LED off digitalWrite(ledPin, LOW); } }