#SENSOR ULTRASONIC
from machine import Pin
from hcsr04 import HCSR04
from time import sleep
medidor = HCSR04 (trigger_pin = 4, echo_pin = 5)
led = Pin (2, Pin.OUT)
while (True):
try:
distancia = medidor.distance_cm()
print("distancia = ", distancia)
if distancia >= 20:
led.value(1)
print("Encendido, alerta")
else:
led.value(0)
print("No hay nadie")
sleep(1)
except:
print(error)
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
ultrasonic1:VCC
ultrasonic1:TRIG
ultrasonic1:ECHO
ultrasonic1:GND