Hi guys
Recently I bought couple HC-SR04 Ultrasonic sensor from ebay. So Yesterday I tested each one of them and they worked fine. Now I would like to test transmitting on one HC-SR04 sensor and receive the ping on another 2 HC-SR04 sensors. However I wired up the circuit below and used the code but all I get on the serial monitor was 0cm. Anyone know where i went wrong?
int TrigPin = 12;
int EchoPin1 = 11;
int EchoPin2 = 10;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin,OUTPUT);
pinMode(EchoPin1,INPUT);
pinMode(EchoPin2,INPUT);
}
void loop()
{
int distance1,duration1,distance2,duration2;
digitalWrite(TrigPin1,HIGH);
delayMicroseconds(11);
digitalWrite(TrigPin1,LOW);
duration1 = pulseIn(EchoPin1, HIGH);//EchoPin received high start counting until the receiver to the low,return to the count valu
distance1 = duration1/29/2;//Calculating the distance cm
duration2 = pulseIn(EchoPin2, HIGH);//EchoPin received high start counting until the receiver to the low,return to the count valu
distance2 = duration2/29/2;//Calculating the distance cm
Serial.print("Echo 1:" + distance1 + "cm" );
Serial.print(" ");
Serial.print("Echo 2:" + distance2 + "cm" );
Serial.println();
delay(1000);
}