Advertisement
naldin

input_int_EVENT_BLINK

May 7th, 2014
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Input teste detecção de evento com blink
  4. # Programa fica em loop até executar CRTL+c ou kill no processo
  5.  
  6. import RPi.GPIO as GPIO
  7. import time
  8.  
  9. GPIO.setwarnings(False)
  10. GPIO.setmode(GPIO.BCM)
  11.  
  12. LED = 18
  13. PIN23 = 23
  14. PIN24 = 24
  15.  
  16. GPIO.setup(LED, GPIO.OUT)
  17. GPIO.setup(PIN23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #com pull-down via sw
  18. GPIO.setup(PIN24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #com pull-down via sw
  19.  
  20. def callback23(channel):
  21.     print "PINO 23 ALTO"
  22.  
  23. def callback24(channel):
  24.     print "PINO 24 ALTO"
  25.  
  26. GPIO.add_event_detect(PIN23, GPIO.RISING, callback=callback23)
  27. GPIO.add_event_detect(PIN24, GPIO.RISING, callback=callback24)
  28.  
  29. while 1:
  30.  
  31.     GPIO.output(LED, GPIO.HIGH)
  32.     time.sleep(1.0)
  33.     GPIO.output(LED, GPIO.LOW)
  34.     time.sleep(1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement