Hi everyone,
i am trying to handle a project, where i want to locate the transmitter (also a ultrasonic sensor) with a few ultrasonic sensors.
I want to use 3 sensors (all in the air) to receive the trigger-signal from transmitter 1 (on the ground). But it actually doesn't work that 2 sensors work together in that way, that sensor 1 is sending the signal out and sensor 2 is receiving the trigger-signal from sensor 1 (his echo). I tried to put some paper on the trigger of sensor 2 (i only need the echo!), but then the Arduino gave out 0 cm.
Both sensors are working individually perfect. But sensor 1 doesn't register the trigger-signal from sensor 2 and the same problem on the other way.
I hope, that someone can help me to fix this problem or if it is not possible,to tell me this.
Enclosed my code.
Best regards
okc1innba
int maximum_distance=700; // should not irritate-> in "one" direction is the distnce unnecessary
int minimum_distance=2;
double measured_distance;
double bygone_time;
void setup() {
pinMode(7,OUTPUT);//Trigger Arduino Sensor 1
pinMode(8,INPUT);//Echo Arduino Sensor 1
pinMode(12,OUTPUT);//Trigger Sensor 2 //paper on it
pinMode(13,INPUT);//Echo Sensor 2
Serial.begin(9600);
}
void loop() {
digitalWrite(12,LOW);
digitalWrite(7,LOW);
delay(10);
digitalWrite(12,HIGH);
digitalWrite(7,HIGH);
delay(10);
digitalWrite(7,LOW);
bygone_time=pulseIn(13,HIGH);
Serial.println(bygone_time); //to overview
measured_distance=bygone_time*0.03432; //temperature irrelevant, if the Project doesn't work
if(measured_distance>=minimum_distance && measured_distance<=maximum_distance)
{
Serial.print("Distance: ");
Serial.print(measured_distance);
Serial.println(" cm");
}
else
{
if(measured_distance<=minimum_distance)
{
Serial.println("Distance to short");
}
else
{
Serial.println("Distance to long");
}
}
delay(1000);
}