Advertisement
DeaD_EyE

Micropython Touch Detect

Nov 12th, 2024 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. pin = Pin(7)
  2.  
  3.  
  4. @micropython.viper
  5. def touch(pin: object) -> int:
  6.     value = 0
  7.     for _ in range(1000):
  8.         pin.init(mode=Pin.OUT, value=1)
  9.         time.sleep_us(2)
  10.         pin.init(mode=Pin.IN, pull=Pin.OPEN_DRAIN)
  11.         value += int(pin())
  12.     return value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement