Advertisement
jn_wp

Push the button

Apr 7th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. from gpiozero import LED, Button
  2. from time import sleep
  3.  
  4. red_led = LED(17)
  5. button = Button(4)
  6.  
  7. red_led.on()
  8. sleep(1)
  9. red_led.off()
  10.  
  11. while True:
  12.     if button.is_pressed:
  13.         print('Button pressed!')
  14.         red_led.on()
  15.         sleep(0.5)
  16.     else:
  17.         red_led.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement