I use two ultrasonic sensors, but only one gives output, the second one gives reading of 0cm.. The weird thing is, when I tried using ONLY the second sensor that didn't give output at first, it gives output of actual centimeter reading.. does it mean i can only use one ultrasonic sensor?
or perhaps it's bcs i connected the sensors at pins that are too closed to each other?
That means you can ONLY use one sensor at a time! Otherwise each one will hear the echo from the other.
Seems you are using a found program that you have modified, as the output of each sensor will be microseconds from the initial pulses to the echo return. Please use serial.Print() to see what the actual microsecond values are returning, not the computed values in centimeters.
The weird thing is it works at one time, now it doesn't work anymore..
i program my left sensor to ping_cm, and if the distance is close, it will turn on relay to pump water.. after that function finished, the second function is ran, where it basically does the same thing, but with the right sensor..