rename dir
This commit is contained in:
parent
95d6e2dfda
commit
11308d1f10
|
@ -1,44 +1 @@
|
|||
#! /usr/bin/python
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
global blinking, blink_count
|
||||
|
||||
blinking: bool = False
|
||||
led_state: bool = False
|
||||
blink_count: int = 0
|
||||
|
||||
LED_PIN = 2
|
||||
BTN_PIN = 3
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(LED_PIN ,GPIO.OUT)
|
||||
GPIO.setup(BTN_PIN,GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
||||
|
||||
blinking = not GPIO.input(BTN_PIN)
|
||||
|
||||
def ISR_DECT_BOTH(channel: int):
|
||||
global blinking, blink_count
|
||||
time.sleep(0.05)
|
||||
blinking = not GPIO.input(BTN_PIN)
|
||||
if(blinking):
|
||||
blink_count = 0
|
||||
|
||||
GPIO.add_event_detect(BTN_PIN, GPIO.BOTH, callback = ISR_DECT_BOTH, bouncetime = 50)
|
||||
|
||||
try:
|
||||
while(1):
|
||||
print(blinking)
|
||||
if(blinking):
|
||||
if led_state == 0:
|
||||
blink_count += 1
|
||||
if blink_count <= 3:
|
||||
led_state = not led_state
|
||||
else:
|
||||
led_state = False
|
||||
GPIO.output(LED_PIN, led_state)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#! /usr/bin/python
|
||||
import RPi.GPIO as GPIO
|
||||
import time
|
||||
|
||||
global blinking, blink_count
|
||||
|
||||
blinking: bool = False
|
||||
led_state: bool = False
|
||||
blink_count: int = 0
|
||||
|
||||
LED_PIN = 2
|
||||
BTN_PIN = 3
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setwarnings(False)
|
||||
GPIO.setup(LED_PIN ,GPIO.OUT)
|
||||
GPIO.setup(BTN_PIN,GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
||||
|
||||
blinking = not GPIO.input(BTN_PIN)
|
||||
|
||||
def ISR_DECT_BOTH(channel: int):
|
||||
global blinking, blink_count
|
||||
time.sleep(0.05)
|
||||
blinking = not GPIO.input(BTN_PIN)
|
||||
if(blinking):
|
||||
blink_count = 0
|
||||
|
||||
GPIO.add_event_detect(BTN_PIN, GPIO.BOTH, callback = ISR_DECT_BOTH, bouncetime = 50)
|
||||
|
||||
try:
|
||||
while(1):
|
||||
print(blinking)
|
||||
if(blinking):
|
||||
if led_state == 0:
|
||||
blink_count += 1
|
||||
if blink_count <= 3:
|
||||
led_state = not led_state
|
||||
else:
|
||||
led_state = False
|
||||
GPIO.output(LED_PIN, led_state)
|
||||
time.sleep(1)
|
||||
except:
|
||||
GPIO.cleanup()
|
||||
|
Loading…
Reference in New Issue