zhexo

Raspberry PI Pico W - PushButton GPIO 22 pull-up

Dec 26th, 2023
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | Software | 0 0
  1. from machine import Pin
  2. import time
  3.  
  4. button = Pin(22, Pin.IN, Pin.PULL_UP) #pin 22 je u pull-up modu
  5.  
  6. while True:
  7.     if button.value() == 0: #pull-up za pritisak daje vrijednost 0
  8.         print("Tipkalo pritisnuto")
  9.     else:
  10.         print("Tipkalo otpusteno")
  11.     time.sleep(0.5) #pauza izmedju ocitanja
Advertisement
Add Comment
Please, Sign In to add comment