SHARE
TWEET

FL2-7-exerc

braconnier Dec 19th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from gpiozero import LED
  2. from time import sleep
  3. import random
  4.  
  5.  
  6. green_led = LED(17)
  7. red_led = LED(27)
  8. yellow_led = LED(22)
  9.  
  10.  
  11.  
  12. #code Morse "SOS"
  13. red_led.blink(0.3,0.7,1,False)
  14. red_led.blink(0.3,0.7,1,False)
  15. red_led.blink(0.3,0.7,1,False)
  16. red_led.blink(1,0.7,1,False)
  17. red_led.blink(1,0.7,1,False)
  18. red_led.blink(1,0.7,1,False)
  19. red_led.blink(0.3,0.7,1,False)
  20. red_led.blink(0.3,0.7,1,False)
  21. red_led.blink(0.3,0.7,1,False)
  22.  
  23. #Random
  24. #while True:
  25. for x in range (10):
  26.     x =random.randint(1,10)*0.2
  27.     print (x)
  28.     green_led.blink(0.3,0.9,1,False)
  29.     sleep(x)
  30.  
  31. #Traffic light
  32. while True:
  33.     green_led.blink(0.3,0.9,1,False)
  34.     sleep(1)
  35.     red_led.blink(1,0.9,1,False)
  36.     sleep(1)
  37.     yellow_led.blink(0.3,0.9,1,False)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top