const int TRIG_OUT = 13;
const int ECHO_IN = 12;
int distance = 0;
void setup() {
// put your setup code here, to run once:
pinMode(TRIG_OUT, OUTPUT);
pinMode(ECHO_IN, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(TRIG_OUT, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_OUT, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_OUT, LOW);
distance = pulseIn(ECHO_IN, HIGH) / 58.0;
Serial.print(distance);
Serial.println("cm");
}