Files
pin_hcrs04.py
and spi_hcrs04.py
both contain
the single class HCSR04
. This has one method .distance_mm()
. pin_hcrs04.py
can use any 2 pins where as
spi_hcrs04.py
can only use pin X7 echo and X8 trigger in position 1 and
pin Y7 echo and Y8 trigger in position 2.
The HCSR04 is a 5 volt device you need to use a logic level shifter. Or you can trigger the device with 3.3v and using a voltage divider on the echo circuit. see http://www.raspberrypi-spy.co.uk/2012/12/ultrasonic-distance-measurement-using-python-part-1/