Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (17 sloc) 602 Bytes
int trigPin=18; //trigPin (18 is a0 in proMicro)
int echoPin=19; //echoPin (19 is a1 in proMicro)
int F_HCSR04()
{
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance >= 200 || distance <= 0) //solo medimos en distancias menores a 2m
distance=1989;
return((int)distance);
}
You can’t perform that action at this time.