-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hcsr04.py reports double the distance #2
Comments
The distance is still wrong, the error is large |
Thats crazy... I now get half the distance! |
hcsr04.py from microbit import *
from machine import time_pulse_us
HIGH = 1
LOW = 0
class HCSR04:
def __init__(self, triggerPin=pin1, echoPin=pin2):
self.triggerPin = triggerPin
self.echoPin = echoPin
self.triggerPin.write_digital(LOW)
self.echoPin.read_digital()
def distance_mm(self):
self.triggerPin.write_digital(HIGH)
self.triggerPin.write_digital(LOW)
micro = time_pulse_us(self.echoPin, HIGH)
return (micro / 2) * 0.34 use
|
@WalterAndreas Try to use it like this, the accuracy is quite high |
Thank you very much! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the hcsr04.py sensor with my microbit reports double the distance.
The text was updated successfully, but these errors were encountered: