Can anyone please show me how to program my arduino duemilanove to use the SRF005 ultrasound?
thanks in advance : )
Can anyone please show me how to program my arduino duemilanove to use the SRF005 ultrasound?
thanks in advance : )
Code
Here’s the code I use to get distance in cm. It’s essentially the same as the Ping sensor. I used the single pin on the SRF05 for both functions:
long getDistance() {
long duration;
pinMode( PING_PIN, OUTPUT );
digitalWrite( PING_PIN, LOW );
delayMicroseconds( 2 );
digitalWrite( PING_PIN, HIGH );
delayMicroseconds( 5 );
digitalWrite( PING_PIN, LOW );
pinMode( PING_PIN, INPUT );
duration = pulseIn( PING_PIN, HIGH );
long d = ( duration / 29 / 2 );
Serial.println( d );
return d;
}