// 2009 mlab.uiah.fi/paja // PING))) Ultrasonic sensor int pingPin = 7; // This pin is connected pin SIG in PING))) Ultrasonic sensor int duration; void setup() { Serial.begin(9600); } void loop() { // Pulse out // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // We give a short LOW pulse beforehand to ensure a clean HIGH pulse. pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); Serial.println(duration); delay(100); }