Prof_Carvalho

Untitled

Feb 25th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import RPi.GPIO as gpio
  5. import time
  6.  
  7. gpio.setmode(gpio.BCM)
  8. gpio.setup(23, gpio.IN, pull_up_down = gpio.PUD_DOWN)
  9. try:
  10.  while True:
  11.   if(gpio.input(23) == 1):
  12.    print(“Botão pressionado”)
  13.   else:
  14.    print(“Botao desligado”)
  15.   time.sleep(0.2)
  16. except:
  17.  gpio.cleanup()
  18. exit()
Advertisement
Add Comment
Please, Sign In to add comment