xathrya

Revisi dari http://pastebin.com/cW36qcjS

Jul 14th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import RPi.GPIO as GPIO
  2.  
  3. RED = 17
  4. GRN = 27
  5.  
  6. def set_LED(color, state):
  7.     GPIO.setwarnings(False)
  8.     GPIO.setmode(GPIO.BCM)
  9.     GPIO.setup(GRN, GPIO.OUT)
  10.     GPIO.setup(RED, GPIO.OUT)
  11.    
  12.     if color == 'red':
  13.         if state == 'on':
  14.             GPIO.output(RED, True)
  15.             return 0
  16.         elif state == 'off':
  17.             GPIO.output(RED, False)
  18.             return 0
  19.         else:
  20.             return 1
  21.     elif color == 'green':
  22.         if state == 'on':
  23.             GPIO.output(GRN, True)
  24.             return 0
  25.         elif state == 'off':
  26.             GPIO.output(GRN, False)
  27.             return 0
  28.         else:
  29.             return 1
  30.     else:
  31.     return 1
Add Comment
Please, Sign In to add comment