Hello, I have built an DIY 40khz ultrasonic sensors to be part of a collision avoidance system for an remote control car but am having some trouble with the programming of it
The ultrasonic transmitter consists of a H-bridge circuit and the receiver consists a amplification circuit and a signal detection circuit.
I have used one of those kit ultrasonic range finders before (HCSR04) and have had no problem using that
Such as:
int sense() { // the main code goes here, to run repeatedly
long duration, distance; //duration used to calculate distance
digitalWrite(trigPin, LOW); //
delayMicroseconds(2); //
digitalWrite(trigPin, HIGH); // this sends out a short pulse for 10ms
delayMicroseconds(10); //
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // when an echo is received the echoPin goes HIGH
distance = (duration/2) * 0.0341 ; // The speed of sound 0.0341 cm/micro second
return distance;
}
Is it not possible to use the same code, or do i have to go a little deeper into the matrix?