Advertisement
naldin

input_int_EDGE_try

May 7th, 2014
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Input teste com detecção de borda usando try
  4.  
  5. import RPi.GPIO as GPIO
  6.  
  7. GPIO.setmode(GPIO.BCM)
  8.  
  9. SWITCH = 23
  10.  
  11. GPIO.setup(SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #com pull-down via sw
  12.  
  13. try:
  14.     GPIO.wait_for_edge(SWITCH, GPIO.RISING) #detecta, escreve e sai do programa
  15.     print("Entrada em nível alto")
  16. except KeyboardInterrupt: #sai do programa com CRTL+c
  17.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement