i reacently got a arduino uno and am trying to understand how it works, under examples>basics>digital read serial youre ment to make a switch, after the switch you put a wire to pin 2 and put a 10k restistor to ground.
after expirimenting a bit i found that the resister to ground is nececarry becase the arduino wil otherwise think the switch is beïng activated, why is this?
i get the resistor but why is a cable to ground nececarry?
The input is "floating" a term used for it doesn't have a definite voltage level.
It is necessary to "pull" the input to a "non-floating" state, so that when the button is pushed the pin goes HIGH, when it is released it goes LOW.
Not to some "random" values.
ok, but is a "floating" voltage level undifined high or low or could it also be in somewhere in the middel
An input not held at a fixed voltage could be at any voltage and what's more that voltage could change over time either slowly or quickly
That is why pullup or pulldown resistors are used to hold the input in a known state
I believe that you have connected your switch as per diagram of Fig-1 and you are taking about the "Jumper Cable" marked in the diagram.
Figure-1:
1. Switch-K1 is at open condition. DPin-2 is pulled down to ground potential by R1 resistor. Now, the logic level at DPin-2 is LOW.
2. If R1 (called pull down resistor) is not installed, the DPin-2 will be at "floating state" and the logic level of DPin-2 is indeterministic (could be any value). So, R1 is installed to keep DPin-2 at a known logic level -- the LOW state.
3. If you don't put the jumper wire and press the switch, the logic level of DPin-2 is still LOW; as result, the close condition of switch is not recognized.
4. Let us put the jumper wire as per Fig-1 and press the switch; as a result, 5V (HIGH) will appear on DPin-2 indicating that the switch has been closed.
5. Various ways of connecting switch:
(1) using external pull up resistor.
(2) Using internal pull up resistor
i made the circuit as in the picture below, i did not know what some of the symbols are but i replaced them with text
the part underlined in black is what i didn't get was necesarry
Your circuit is same as circuit of Fig-1 of post #5 except the unconnected thin black line.
If you were to take your multimeter and the above schematic and measure the input on pin2 would it be a ground or a V+ or something else?
Using the above schematic and putting a wire across the 10K resistor and then flipping the switch what would you measure on pin2? You may find that directly shorting the 5V signal to ground may produce smoke.
You may find this helpful. Read about pullup resistors.
This is a common question in one form or another, this should help:
thanks this was helpfull and i now get why the ground line is necesarry
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.