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.

41 lines
780 B

from pinouts import NodeMCU as pins
from hcsr04 import HCSR04
import time
import machine
def blink():
pin = machine.Pin(2, machine.Pin.OUT)
while True:
pin.value(not pin.value())
time.sleep_ms(500)
def distance():
5 years ago
sensor = HCSR04(trigger_pin=pins.D3, echo_pin=pins.D4)
while True:
print(sensor.distance_cm())
time.sleep(1)
5 years ago
def movement():
sensor = machine.Pin(pins.D2, mode=machine.Pin.IN, pull=None)
5 years ago
while True:
print(sensor.value())
5 years ago
time.sleep(0.5)
def toggleRaiseUp():
relayUp = machine.Pin(pins.D2, mode=machine.Pin.OUT)
relayUp.value(not relayUp.value())
def toggleLowerDown():
relayDown = machine.Pin(pins.D3, mode=machine.Pin.OUT)
relayDown.value(not relayDown.value())