You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
745 B

from pinouts import NodeMCU as pins
from hcsr04 import HCSR04
import time
import machine
def getDistance():
sensor = HCSR04(trigger_pin=pins.D2, echo_pin=pins.D3)
return sensor.distance_cm()
def getMovement():
sensor = machine.Pin(pins.D2, mode=machine.Pin.IN, pull=None)
return sensor.value()
def resetRelay():
relayUp = machine.Pin(pins.D5, mode=machine.Pin.OUT)
relayDown = machine.Pin(pins.D6, mode=machine.Pin.OUT)
relayUp.value(1)
relayDown.value(1)
def toggleRaiseUp():
relayUp = machine.Pin(pins.D5, mode=machine.Pin.OUT)
relayUp.value(not relayUp.value())
def toggleLowerDown():
relayDown = machine.Pin(pins.D6, mode=machine.Pin.OUT)
relayDown.value(not relayDown.value())