# Beginner's question.

I've just started out with arduino and its pretty interesting (I've programmed in java so I'm getting a hang of things pretty quickly) But I'm having a bit of an issue understanding the electronics. I've read several books on the basics of electronics. I get the principles of resistance, capacitance, transistors, semiconductors, etc. But I haven't done much electronics based upon more complex circuitry. So the idea of a pull down resistor is foreign for me. I'm trying to understand how a pull-down resistor works, and what it specifically does (I know that it can be any electrical load.

For example, the push button circuit. I started up a project on my own to see if I had the basics down a bit. This basic circuitry was to take an input from a push button and use an analog output to dim an LED. I tried originally just linking the switch through the ground to the pin because I figured the input pin was a kind of positive terminal (I think in terms of from negative to positive with current). This didn't work and after looking back I realized I needed to link the button from ground with a resistor to the positive end and that the sensor pin is hooked in between the resistor and the switch. This confuses me for several reasons. What kind of polarity is the pin? If it is positive then why does the resistor need to be there, shouldn't the low just be no current running between the ground and pin. If it is negative, why does it need the resistor if it can go straight from the pin through the switch to the positive terminal. I just don't understand the mechanism of how it works.

Could someone please explain how this mechanism works. I'm a bit confused. and I figure if I don't understand why it needs one here then I won't know when some other part of my circuit will need one.

If anyone is willing, it would be very much appreciated : )

An unconnected input pin is not necessarily at either high or low, it'll just be at some random voltage depending on the phase of the moon and your sock colour.

When you attach it thru a switch to say 5V, obviously it's high. But just before that? When it was not connected to 5V, what was it?- who knows. What colour socks are you wearing today.

So, to guarantee that it's low and not just random up to when you hit the switch to 5V, the pin can be connected to ground to give at a known state. That of course one could do with a mere wire.

So why a resistor? Look at any circuit involving a pull down: you'll see that when the switch is closed, the 5V would go thru the switch, thru the "pull down wire" and go to ground with no resistance- that would be a dead short. So a resistor is put in there to prevent the dead short. To all intents and purposes, the 5V is then visible at the pin.

(As an alternative, there are also pull UP resistors, where the known normal state would be 5V, and when the switch is pressed it goes to 0V. Which one you use depends on which way you want your logic to work. The Arduino has internal pull UPs which can be enabled in code: `pinMode (myPin, INPUT_PULLUP); `

I’m not an engineer either and I don’t have time to do a course in electronics (I tried it once), so I’ve got the idea that there is a lot of info on the web for the sort of things I want to do, and someone would have already designed a circuit for the job I’m doing. Take a look at the top of this page, a guy has designed heaps of circuits for different things which are worth looking at. It’s a choice between spending time understanding how to do things yourself, or pinching someone elses ideas. I’ve decided I’ll go the second route, it will save a lot of time.

Good luck with whatever you decide.

By the way, either the pull UP or DOWN forms a Voltage Divider.

Vpin = 5 x (Z2 / (Z1 + Z2))

In the case of the pull up or down, one side is wire which is basically resistance free.

With a pull-down, Z1 ~ 0, so Vpin ~5V

With a pull-up, Z2~0, so Vpin ~ 0V

Thanks everyone. I'm still a little confused, but you've definitely contributed. Also, don't worry, I wouldn't let this question stop me from using arduino or working with it. I was just a little curious to see how things work, I'm always up to learn and do and boy do I think arduino is going to be fun.

I've thinking an automated hydroponics system could be an interesting project.

All the best and have a fantastic day/evening/time of day everyone.

By far the easiest way is to use the built-in pullup, since you don't have to mess about with external parts.

``````pinMode(myPin, INPUT_PULLUP);
``````

Just think about the logic... this method is known as "active low". When the button is not-pressed (ie inactive), the pin is high, held at 5V by the internal pull-up.

Push the button.... (ie make it active) and the pin is taken to ground, low, 0V. Hence the name active low.

You just need to account for that in the way you process the button push in your code by reading the pin. Probably along the lines of if the pin is high (inactive) do nothing, if it's low (active) do stuff.