hi everyone.
in my project I need to build a ping ultrasonic transmitter and use another ping sensor to receive that signal,to test that method I removed the emitter from one of the pings and the receive from the other one,and I modified the arduino ping example sketch to test it,so one of pings will send the signal and the other one receive it . but that didn't work ,what kind of method should I use
here is the code
const int pingPin1 = 7;
const int pingPin2 = 8;
void setup() {
Serial.begin(9600);
}
void loop()
{
long duration, inches, cm;
pinMode(pingPin1, OUTPUT);
digitalWrite(pingPin1, LOW);
delayMicroseconds(2);
digitalWrite(pingPin1, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin1, LOW);
pinMode(pingPin2, INPUT);
duration = pulseIn(pingPin2, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
My guess is the receiver didn't listen, because it didn't get a trigger pulse to transmit.
yes ,by using the serial monitor it shows that it didn't read the ultrasonic signal(it shows 0cm,0inch),and I am using the same arduino uno for both pings
I am sorry but I don't know how to use the code tags