/********* Rui Santos Complete project details at https://RandomNerdTutorials.com/raspberry-pi-pico-outputs-inputs-arduino/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. *********/ // set pin numbers const int buttonPin = 21; // the number of the pushbutton pin const int ledPin = 20; // the number of the LED pin // variable for storing the pushbutton status int buttonState = 0; void setup() { Serial.begin(115200); // initialize the pushbutton pin as an input pinMode(buttonPin, INPUT_PULLDOWN); // initialize the LED pin as an output pinMode(ledPin, OUTPUT); } void loop() { // read the state of the pushbutton value buttonState = digitalRead(buttonPin); Serial.println(buttonState); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH if (buttonState == HIGH) { // turn LED on digitalWrite(ledPin, HIGH); } else { // turn LED off digitalWrite(ledPin, LOW); } }