distance = duration/58.2;
if (distance >= maximumRange || distance <= minimumRange){// Yellow led indicated out of maximumRange. Prints “Out Of Range” to serial if target is outside maximumRange.Serial.println(“Out Of Range”);
digitalWrite(LEDPinYellow, HIGH);
digitalWrite(LEDPinGreen, LOW);
Quelle: https://patakacs.wordpress.com/2014/02/04/ultrasonic-sensor-hc-sr04-and-piezo-speakers-measuring-distance-and-playing-a-tone-with-piezo/
“This document can be copied and modified under the conditions of GNU General Public License. [http://www.gnu.org/licenses/gpl.html http://www.gnu.org/licenses/gpl.html]“