Adding file
This commit is contained in:
parent
b393ce6538
commit
99dc268057
1 changed files with 23 additions and 5 deletions
|
@ -1,6 +1,9 @@
|
|||
import flask
|
||||
from RPi import GPIO
|
||||
import time
|
||||
import threading
|
||||
|
||||
app = flask.Flask(import_name=__name__)
|
||||
|
||||
motor_pin1 = 38
|
||||
motor_pin2 = 40
|
||||
|
@ -9,7 +12,7 @@ GPIO.setmode(GPIO.BOARD)
|
|||
GPIO.setup(motor_pin1, GPIO.OUT, initial=GPIO.LOW)
|
||||
GPIO.setup(motor_pin2, GPIO.OUT, initial=GPIO.LOW)
|
||||
|
||||
def switch_off(mini_rotation_counter=20):
|
||||
def switch_off(mini_rotation_counter=30):
|
||||
GPIO.output(motor_pin1, GPIO.LOW)
|
||||
GPIO.output(motor_pin2, GPIO.LOW)
|
||||
for _ in range(mini_rotation_counter):
|
||||
|
@ -18,7 +21,7 @@ def switch_off(mini_rotation_counter=20):
|
|||
GPIO.output(motor_pin2, GPIO.LOW)
|
||||
time.sleep(0.2)
|
||||
|
||||
def switch_on(mini_rotation_counter=20):
|
||||
def switch_on(mini_rotation_counter=30):
|
||||
GPIO.output(motor_pin1, GPIO.LOW)
|
||||
GPIO.output(motor_pin2, GPIO.LOW)
|
||||
for _ in range(mini_rotation_counter):
|
||||
|
@ -27,9 +30,24 @@ def switch_on(mini_rotation_counter=20):
|
|||
GPIO.output(motor_pin1, GPIO.LOW)
|
||||
time.sleep(0.2)
|
||||
|
||||
def into_thread():
|
||||
for _ in range(7):
|
||||
switch_on()
|
||||
switch_off()
|
||||
switch_off()
|
||||
|
||||
@app.route("/open")
|
||||
def open_command_function():
|
||||
"""for _ in range(7):
|
||||
switch_on()
|
||||
switch_off()
|
||||
switch_off()"""
|
||||
command_applier = threading.Thread(target=into_thread)
|
||||
command_applier.start()
|
||||
return "Pull the door ;)"
|
||||
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
switch_off()
|
||||
time.sleep(2)
|
||||
switch_on()
|
||||
time.sleep(2)
|
||||
app.run(host="0.0.0.0")
|
Loading…
Reference in a new issue