Hi, I am new to Arduino and have managed to get along quite well but seem to get stuck on one particular aspect - receiving the status of a switch.
I am intending to use arduion to control signals on a mdel railway and have been playing with the popular traffic light examples especially the traffic light with a pedestrian crossing button press.
I just cannot get the button to work however hard I try. With the model railway I simply want to replace the switch with infrared detection - sounds easy but the ** switch is just not playing ball.
Any help would be aprreciated.
Post your code, post a schematic.
A common noob problem is not using a pullup or pull-down resistor on the switch input pin.
Test the switch with a meter when connected and see if it goes below 1V and above 4V when on and off. If not you found the problem. I always use pull up or down resistors on all my switch circuits. I want a minimum of 1 Ma current to flow keeping the contacts clean. This requires a resistor less then 5K, I use 4.7K. This comes from many years ago and it has never gotten me into trouble and the switches keep working. In software you can define On and Off with GRUE and FALSE. I generally do this in all programs, it keeps coding much simpler. Be careful of bad connections. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
gilshultz:
I want a minimum of 1 Ma current to flow keeping the contacts clean.
sp. "1mA"
...
GRUE and FALSE.
sp. "HIGH and "LOW"
This response is to stop you getting confused.