Hello my friends couldnt find an answer on the forum about what i want,so..
I got an ultrasonic sensor,i uploaded a sample sketch so i could see if the measurements where right,then sudenly after some distance changes my ping(serial print measurement goes to 0 and stayed over there for ever.I searched it and i try to reset it somehow,i found an if statement that you just making output the echo pin ,then make it LOW and again input
if ( sonar.ping_cm() == 0 )
{pinMode(ECHO_PIN, OUTPUT);
digitalWrite(ECHO_PIN, LOW);
delay(1);
pinMode(ECHO_PIN, INPUT);
}
It was working allright,but i keep getting zeros (0) sometimes,its reseting but i keep getting them and i dont wont that...here is why, I just made a homemade security alarm with many sensor including the ultrasonic, so i was getting random zeros and my siren cought that zeros and it was high again and again for noreason,then i searched again and i found the library NEWPING.
I tryed the sample sketch but i got the same problem,then i tryed the timer sketch,and it work perfectly for every insta distance check,but it was stopping the triggering,and then after a time it was starting again, i dont know how to control the time for the trigger to be high to increase the value,there is any option-feature in that library that i can send pings for ever and just ignore the zeros? im not talking about max distance, i got a standard obstickle before the max distance.
I dont want for any random reason to give me 0 when the distance is not zero.
thats all ,can you suggest me a sample of code so i can ping forever and ignore zeros? thank you very much and sorry for my english