lift.py
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P8_14", GPIO.IN) #pushButton pin1 for floor1
GPIO.setup("P8_16", GPIO.IN) #pushButton pin2 for floor2
GPIO.setup("P8_18", GPIO.IN) #pushButton pin3 for floor3
floor=0
GPIO.setup("P8_10", GPIO.OUT) #floor1 LED
GPIO.setup("P8_12", GPIO.OUT) #floor2 LED
GPIO.setup("P8_8", GPIO.OUT) #floor3 LED
cF=1
while True:
if(GPIO.input("P8_14")==1): #to go on floor 1
if(cF==1): #if current floor is 1
GPIO.output("P8_8",GPIO.HIGH)
cF=1
elif(cF==2): # if current floor is 2
GPIO.output("P8_10",GPIO.LOW) #OFF LED 2
GPIO.output("P8_8",GPIO.HIGH) #ON LED 1
cF=1
elif(cF==3): #if current floor is 3
GPIO.output("P8_12",GPIO.LOW) #OFF LED3
GPIO.output("P8_10",GPIO.HIGH)#ON LED2
time.sleep(2.0)
GPIO.output("P8_10",GPIO.LOW) #OFF LED2
GPIO.output("P8_8",GPIO.HIGH) #ON LED 1
cF=1
elif(GPIO.input("P8_16")==1):
f=2
if(cF==1):
GPIO.output("P8_8",GPIO.LOW)
GPIO.output("P8_10",GPIO.HIGH)
cF=2
#time.sleep(10.0)
#GPIO.output("P8_10",GPIO.LOW)
elif(cF==2):
GPIO.output("P8_10",GPIO.HIGH)
cF=2
elif(cF==3):
GPIO.output("P8_12",GPIO.LOW)
GPIO.output("P8_10",GPIO.HIGH)
cF=2
elif(GPIO.input("P8_18")==1):
f=3
if(cF==1):
GPIO.output("P8_8",GPIO.LOW)
GPIO.output("P8_10",GPIO.HIGH)
time.sleep(2.0)
GPIO.output("P8_10",GPIO.LOW)
GPIO.output("P8_12",GPIO.HIGH)
cF=3
elif(cF==2):
GPIO.output("P8_10",GPIO.LOW)
GPIO.output("P8_12",GPIO.HIGH)
cF=3
elif(cF==3):
GPIO.output("P8_12",GPIO.HIGH)
cF=3
No comments:
Post a Comment