Skip to content

Conversation

xmeow
Copy link

@xmeow xmeow commented Jan 5, 2021

This should resolve #26, make hcsr04 works with newbit. Tested with the following code snippet:

def sonar(p):
  p.write_digital(0)
  sleep_us(2)
  p.write_digital(1)
  sleep_us(10)
  p.write_digital(0)
  p.read_digital()
  duration = p.pulsein(2000)
  if duration<0:
    return -1
  return (duration/2)/29.1

@dpgeorge
Copy link
Collaborator

dpgeorge commented Feb 8, 2021

Thanks for the contribution!

machine.time_pulse_us() should now be fixed by b7a76e4

The change in this PR adds a new method to pins, which changes (expands) the existing API so is probably not the best way to do it (because then it becomes hard to write code that works on V1 and V2).

@xmeow xmeow closed this Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sonar sensor problem(hcsr04) - time_pulse_us

2 participants