SimpleIDE HCSR04 Library for Propeller
February 21, 2014
Since there are so many of us adding Propeller to the arsenal these days, I decided to try my hand at building a library. Parallax is of course famous for their $30, 3-pin ultrasonic unit which other than pinout looks exactly like the cheaper HCSR04 modules that most of us have floating around. This was just an experiment to port the code from Arduino to Prop C and it works just like you'd expect. There are three functions, HCSRping, HCSR_cm and HCSR_inches, and each takes two arguments-trigger and echo pins, in that order.
I haven't tested this with multiple sensors but I don't imagine it will cause any problems. There are no pauses (except in the demo where it pauses a half second between reads in the terminal.) It probably wouldn't matter much with the cog assignment system though.