what effect does changing the code higlighted below in red have on the readings of the ping US sensor?
int pingPin = 7;
void setup()
{
Serial.begin(9600);
}
void loop()
{
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
long microsecondsToInches(long microseconds)
{
// According to Parallax's datasheet for the PING))), there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// We give a short LOW pulse beforehand to ensure a clean HIGH pulse.
You are changing the time the pulse is high to 5 micro seconds, but acording to the comment above, the pulse should be 2 OR MORE micro seconds, so it probably doesen't have any negative effect.
The question is What was it before you changed it, and why do you want to change it ?
no i knw bout that... it is set to 5 at default, which is why i was wondering why didnt they set it to 2... and when i tried the code with 2 instead, i didnt notice any difference, so thats y i asked if there is really a change that occurs with the variance of this value
Longer pings have more energy in them, and hence allow detection at longer ranges. But, longer pings reduce range resolution and increase the minimum range at which you can detect a target.
so if i set the value to 2, i will get "better" results and closer that if i used say 10 - then id be able to detect a longer distance, but the minimum distance would be increased as well?
which is why i was wondering why didn't they set it to 2
For a beginner it is difficult to know that some things are just a guess in the right order of magnitude and that it doesn't matter much the exact value. For example the base resistor in a transistor could be anything between 1K and 10K with out it mattering much. I suspect they tried 5mS and that worked so they stuck to it.
i guess ure right, i just needed to knw cause il be working on some pretty sensitive calculations in a VERY large project which i plan to build around microchips such as the atmega... so i needed to knw if changing this value makes a difference in the output values of the sensor
btw, since i have ure attention, i wanted to ask about these baords i often see at electronics stores... just like the usual pcb baords, they have equally spaced holes, yet the ones ive been noticing do not have a few of such holes for components linked in rows, but instead each hole is seperate... how does this work? are u supposed to connect them using solder or like what?
im not sure i completely understand... can u aid my ignorance my hooking me up with a link to a lesson on how to do this or alteast an img of this so that i can figure it out from there? k thx
When using prototyping board without copper tracks, the idea is to bend to component leads over on the back of the board. The leads then form "tracks" in whatever arrangement you want. You can solder them down at the intermediate pads if required.