SHARE
TWEET

Fish Dish Snippet for Raspberry PI

a guest Jan 31st, 2014 1,084 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import RPi.GPIO as GPIO
  3. import time
  4.  
  5. LEDGPIOPin_Gruen = 4
  6. LEDGPIOPin_Rot = 9
  7. LEDGPIOPin_Gelb = 22
  8. LEDGPIOPin_BUZZ = 8
  9. LEDGPIOPin_BUTTON = 7
  10.  
  11. GPIO.setmode(GPIO.BCM)
  12. GPIO.setwarnings(False)
  13.  
  14. GPIO.setup(LEDGPIOPin_Gruen, GPIO.OUT)
  15. GPIO.setup(LEDGPIOPin_Gelb, GPIO.OUT)
  16. GPIO.setup(LEDGPIOPin_Rot, GPIO.OUT)
  17.  
  18. GPIO.setup(LEDGPIOPin_BUZZ, GPIO.OUT)
  19.  
  20. GPIO.setup(LEDGPIOPin_BUTTON, GPIO.IN)
  21.  
  22. GPIO.output(LEDGPIOPin_Rot, GPIO.LOW)
  23. GPIO.output(LEDGPIOPin_Gruen, GPIO.LOW)
  24. GPIO.output(LEDGPIOPin_Gelb, GPIO.LOW)
  25.  
  26. DELAYON = 1.0
  27. DELAYBUZZ = 0.1
  28.  
  29. while True:
  30.         if (GPIO.input(LEDGPIOPin_BUTTON) == True):
  31.                 GPIO.output(LEDGPIOPin_Rot, GPIO.HIGH)
  32.                 i = 1
  33.                 while i < 30:
  34.                         GPIO.output(LEDGPIOPin_BUZZ, GPIO.HIGH)
  35.                         time.sleep(DELAYBUZZ)
  36.                         GPIO.output(LEDGPIOPin_BUZZ, GPIO.LOW)
  37.                         time.sleep(DELAYBUZZ)
  38.  
  39.                         if (i == 10):
  40.                                 GPIO.output(LEDGPIOPin_Gelb, GPIO.HIGH)
  41.                         if (i == 20):
  42.                                 GPIO.output(LEDGPIOPin_Gruen, GPIO.HIGH)
  43.                         i += 1
  44.         else:
  45.                 GPIO.output(LEDGPIOPin_Rot, GPIO.LOW)
  46.                 GPIO.output(LEDGPIOPin_Gruen, GPIO.LOW)
  47.                 GPIO.output(LEDGPIOPin_Gelb, GPIO.LOW)
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