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.
|
|
|
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():
|
|
|
|
sensor = HCSR04(trigger_pin=pins.D0, echo_pin=pins.D3)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
print(sensor.distance_cm())
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
def movement():
|
|
|
|
sensor = machine.Pin(pins.D1, mode=machine.Pin.IN, pull=None)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
print(sensor.value())
|
|
|
|
time.sleep(1)
|