cable Wire a switch
Use 1 socket-to-socket jumper wire and 1 pin-socket jumper wire.
# Import the Switch component
from picozero import Switch
from time import sleep
# Set up Switch with correct pin number
switch_1 = Switch(18)
# Check Switch state in a loop
while True:
if switch_1.is_closed:
print("Switch is closed")
else:
print("Switch is open")
sleep(0.1) # small delay
bug_report My Switch doesn't work
- Check your connections.
- Check the pin number in your code.
- Check that your code is indented correctly.