Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Read the Button connected to Raspberry Pi Pico and toggle the status of LED.
#Import Pin class from machine library to configure GPIO Pins.
from machine import Pin
#Import utime library to implement delay
import utime
#create an object of Pin class and set GPIO Parameters (GPIO Pin, Direction).
ledPin = Pin(16, Pin.OUT)
buttonPin = Pin(15, Pin.IN, Pin.PULL_DOWN)
#Create an infinite loop. This is similar to while(1) in C.
while True:
if buttonPin.value() == 1:
Copy link

Line 10: if buttonPin.value():

any content other than 0 and False is Truth in Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment