1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(22,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
#----------------------------------------------------------------------
def interruption(void):
variable = 1
def led_blinky():
GPIO.output(17,GPIO.HIGH)
time.sleep(1.0/20)
GPIO.output(17,GPIO.LOW)
#--------------------------------------------------------------------
GPIO.add_event_detect(22,GPIO.RISING,callback=interruption,bouncetime=100)
GPIO.output(17,GPIO.LOW)
while(1):
if variable == 1:
led_blinky
variable = 0
time.sleep(1.0/1000)
#----------------------------------------------------------------------- |
Partager