MicroPython_ESP32_psRAM_LoBo icon indicating copy to clipboard operation
MicroPython_ESP32_psRAM_LoBo copied to clipboard

I don't know what to do here

Open Rafoni-py opened this issue 7 months ago • 0 comments

I'm using this code to make an ultrasound measuring tape and a led need to turn on if the distance is equal or less than 10 cm but it just don't work

`from machine import Pin, time_pulse_us from time import sleep_ms, sleep_us

trg = Pin(13, Pin.OUT) ech = Pin(23, Pin.IN) led = Pin(26, Pin.OUT, 1) var1 = time_pulse_us(ech, 1, 20000)

while True: trg.off() sleep_us(5) trg.on() sleep_us(10) trg.off()

t = time_pulse_us(ech, 1, 20000)
d = t / 58.8
print (d)
sleep_ms(2000)

if d <= 3 and d <= 10 led.on() (True) else: led.off() `

Rafoni-py avatar Apr 04 '25 19:04 Rafoni-py