Skip to content

I don't know what to do here #344

Description

@Rafoni-py

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()
`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions