complete newbie here, I am trying to make it so an Led will only turn on when it is within 100 centimeters of the ultrasonic sensor and a button is pressed. if the code isn't the problem it must be the wiring? is a 100k ohm resistor too much for the button? also i have both the ultrasonic sensor's and the buttons ground pin connected to one row on the side which goes straight to the GND on the arduino board(i don't think that should be an issue right?)
i tried it with a 10k resistor and it still didn't work
edit: the ultrasonic sensor is also acting odd it gives the correct distance but instantly follow it up with a zero. it's also slower than the "PING" example arduino provides...
And how does this compute when the duration is ZERO? Instead of printing after the calculation, temporarily print the duration value so you can debug your program.
I tried copying the Ping example on arduino and don't understand how this works very well i don't understand a lot of the terms you used but did you mean something like this?
cm = microsecondsToCentimeters(duration);
duration = pulseIn(echoPin, HIGH);
Serial.print(cm);
Serial.print("cm");
Serial.println();
This says: the variable cm is assigned the value returned from the function microsecondsToCentimeters(); using the value of duration in its calculation.
@8uzztronic - You have a few topics started and unfinished. All of them start with excusing yourself for being new, then saying you guessed at a few random things using random power, and all of them create errors.
It would be nice if you would learn.
Start with; Read the help for which you asked. Act on the help. Show results from acting on the help. Explain your observations on how the help brought your project/topic to a close. Learn from the mistakes and the help. Continue doing this with ONLY ONE project until it is complete.
None of your topics are complete. You are burning up people's time and doing nothing with it. Only one step at a time.