Advertisement
noam76

open_close damper

Apr 19th, 2019
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import time
  2. # import RPi.GPIO as GPIO
  3. MOTOR_TIMEOUT = 3
  4. target_temp = 23
  5. local_temp = 20
  6. operation_motor_start = 0
  7. motor_running = False
  8.  
  9. def damper_motor_driver():
  10.     global motor_running
  11.     global operation_motor_start
  12.     if motor_running == True:
  13.         current_motor_time = time.time()
  14.         if current_motor_time - operation_motor_start > MOTOR_TIMEOUT:
  15.             motor_running = False
  16.             operation_motor_start = 0
  17.             #GPIO.output(_MotorR,GPIO.LOW)
  18.             #GPIO.output(_MotorL,GPIO.LOW)
  19.             print("GOOD The time is ending")
  20.            
  21. def open_damper():
  22.     global operation_motor_start
  23.     global motor_running
  24.     motor_running = True
  25.     operation_motor_start = time.time()
  26.     #GPIO.output(_MotorR,GPIO.LOW)
  27.     #GPIO.output(_MotorL,GPIO.HIGH)
  28.    
  29. def close_damper():
  30.     global operation_motor_start
  31.     global motor_running
  32.     motor_running = True
  33.     operation_motor_start = time.time()
  34.     #GPIO.output(_MotorR,GPIO.HIGH)
  35.     #GPIO.output(_MotorL,GPIO.LOW)
  36.  
  37. while True:
  38.   damper_motor_driver()
  39.   if target_temp > local_temp:
  40.     close_damper()
  41.     local_temp = 25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement