Merged the Pulsein/out code from: https://github.com/jgautier/arduino-1/tree/pulseIn
Tested using https://github.com/rwldrn/johnny-five ping example