Advertisement
KRITSADA

RPi Check 2 switch with AND

Apr 23rd, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. pins = [5,6,27]
  4. GPIO.setmode(GPIO.BCM)
  5. GPIO.setup(24,GPIO.IN)
  6. GPIO.setup(25,GPIO.IN)
  7. for x in pins :
  8.     GPIO.setup(x,GPIO.OUT)
  9. for x in pins :
  10.     GPIO.output(x,0)
  11. try:
  12.     while (True) :
  13.         if GPIO.input(24) and GPIO.input(25) :
  14.             GPIO.output(5,1)
  15.         else :
  16.             GPIO.output(5,0)
  17. finally:
  18.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement