diff --git a/commands_executor.py b/commands_executor.py new file mode 100644 index 0000000..a72dcd6 --- /dev/null +++ b/commands_executor.py @@ -0,0 +1,35 @@ +import flask +from RPi import GPIO +import time + +motor_pin1 = 38 +motor_pin2 = 40 + +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): + GPIO.output(motor_pin1, GPIO.LOW) + GPIO.output(motor_pin2, GPIO.LOW) + for _ in range(mini_rotation_counter): + GPIO.output(motor_pin2, GPIO.HIGH) + time.sleep(0.002) + GPIO.output(motor_pin2, GPIO.LOW) + time.sleep(0.2) + +def switch_on(mini_rotation_counter=20): + GPIO.output(motor_pin1, GPIO.LOW) + GPIO.output(motor_pin2, GPIO.LOW) + for _ in range(mini_rotation_counter): + GPIO.output(motor_pin1, GPIO.HIGH) + time.sleep(0.002) + GPIO.output(motor_pin1, GPIO.LOW) + time.sleep(0.2) + + +if __name__=="__main__": + switch_off() + time.sleep(2) + switch_on() + time.sleep(2) \ No newline at end of file