I currently have a Parallax ping sensor, and some code I found and modified to actually return accurate results... well as accurate as i can get without being able to print Floats..
the Ping is supposed to read out to 3m..
It works great out to about 12-16" however after that my echo jumps to ~21000 ms
Do I have a problem with my code or hardware ...
I have adjusted my holdoff from 0 to 500 with no effect
I have removed the Pullup and used while to wait for LOW
I have increased and decreased my trigger to both acceptable extremes.
Any help would be appreciated.
I've turned this in a function that is called every delay(250);
unsigned long ping(){
pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
digitalWrite(ultraSoundSignal, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(ultraSoundSignal, LOW); // Holdoff
delayMicroseconds(400); // Wait for 4 microseconds
pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
digitalWrite(ultraSoundSignal, HIGH); // Turn on pullup resister
echo = pulseIn(ultraSoundSignal, HIGH); //Listen for echo
//cursorSet(1,0); // from my LCD conroller lib
// Serial.print(" ");
//cursorSet(1,0); // from my LCD conroller lib
//Serial.print(echo); // used for debug...
ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches
return ultrasoundValue;
}