included button check
This commit is contained in:
parent
183732b5ad
commit
3405114cba
20
LED_check.py
20
LED_check.py
@ -19,6 +19,9 @@ def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin):
|
||||
GPIO.setup(Button1_pin, GPIO.IN)
|
||||
GPIO.setup(Button2_pin, GPIO.IN)
|
||||
|
||||
# GPIO.setup(Button1_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
# GPIO.setup(Button2_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
|
||||
return LED_status
|
||||
|
||||
|
||||
@ -38,7 +41,10 @@ def main():
|
||||
|
||||
t0 = time()
|
||||
|
||||
while time() - t0 < 10:
|
||||
loop_t = time()
|
||||
|
||||
while time() - t0 < 5:
|
||||
print(time() - loop_t)
|
||||
# LED1 blink every 2 sec
|
||||
if time() - LED1_t < .1 and LED_status[0] == False:
|
||||
LED_status[0] = True
|
||||
@ -62,6 +68,18 @@ def main():
|
||||
if time() - LED2_t >= LED2_t_interval:
|
||||
LED2_t = time()
|
||||
|
||||
|
||||
# button press check !!!
|
||||
if GPIO.input(Button1_pin) == GPIO.HIGH:
|
||||
print('button 1 pressed')
|
||||
|
||||
if GPIO.input(Button2_pin) == GPIO.HIGH:
|
||||
print('button 2 pressed')
|
||||
|
||||
|
||||
loop_t = time()
|
||||
|
||||
|
||||
GPIO.cleanup()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user