Hi - I'm afraid the GH-311 isn't really very useful at all. I've just googled it and it gives a single output: High when you're near to it, and Low when you're far away - there is no distance measurement.
So you can't use it with the HC-SR04 driver... The best you could do is:
setWatch(function(e) {
if (e.state) console.log("In Range");
else console.log("Out of Range");
}, SENSOR_PIN, { repeat: true });
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - I'm afraid the GH-311 isn't really very useful at all. I've just googled it and it gives a single output: High when you're near to it, and Low when you're far away - there is no distance measurement.
So you can't use it with the HC-SR04 driver... The best you could do is: