def openClose(number):
global condition, servoDeur
if GPIO.event_detected(knopBinnen):
if (condition == "closed"):
servoDeur.ChangeFrequency(50)
servoDeur.start(0)
print("Gedrukt Binnen")
condition = "opened"
connection.setDataToDatabaseMetingenMetVerandering(sensor.print_temp(), "temperature", "Door closed manually")
servoDeur.ChangeDutyCycle(2.5)
time.sleep(3)
servoDeur.stop()
else:
servoDeur.ChangeFrequency(50)
servoDeur.start(0)
print("Gedrukt Binnen 2")
condition = "closed"
connection.setDataToDatabaseMetingenMetVerandering(sensor.print_temp(), "temperature", "Door opened manually")
servoDeur.ChangeDutyCycle(6)
time.sleep(3)
servoDeur.stop()
time.sleep(0.0025)
if GPIO.event_detected(knopBuiten):
if (condition == "opened"):
servoDeur.ChangeFrequency(50)
servoDeur.start(0)
print("Gedrukt Buiten ")
condition = "opened"
connection.setDataToDatabaseMetingenMetVerandering(sensor.print_temp(), "temperature", "Door opened manually")
servoDeur.ChangeDutyCycle(6)
else:
servoDeur.ChangeFrequency(50)
servoDeur.start(0)
print("Gedrukt Buiten 2")
condition = "opened"
connection.setDataToDatabaseMetingenMetVerandering(sensor.print_temp(), "temperature", "Door closed manually")
servoDeur.ChangeDutyCycle(2.5) # turn towards 180 degree
time.sleep(3)
servoDeur.stop()
time.sleep(0.0025)
评论列表
文章目录