gamegine/HCSR04-ultrasonic-sensor-lib

Multiple HC-SR04 issue

PouletxD opened this issue · 3 comments

Hello !

I've installed your HC-SR04 library.

Once I'm trying the multiple sensor way, with the following code : HCSR04 hc(3,new int[2]{2,5},2); (there are 2 sensors)
and

{ for (int i = 0; i < 2; i++ ) {Serial.println( hc.dist(i) );} }

I got the following error

no matching function for call to 'HCSR04::HCSR04(int, int*, int)'

Thank you!

Hello
are you on 2.0.1 version of the library ?
if you are on version 2.0.0 you need to to use the old constructor
HCSR04 hc (2, new int [6] {5,6,7,8,9,10});
but I recommend switching to the new version to avoid errors

That was indeed a problem of version.

But I still have an issue ; only one of my two sensors display a value, while the other only display "0".

Do you have any idea about it ?

probably your obstacle is too far or has a bad angle that prevents the impulse from returning to the sensor and therefore returns 0