Resistors - When to use and how

hi guys. just got my first set of arduino gear today! i have a high level question. ive read Mim's books on electronics. and ive read countless things online about electronics. but my mind could never make the jump it needs to. i see all kinds of circuits (now one in "getting started with arduino") which is very simple but has a resistor. i know what resistors do, but i dont know when and how to use them. my circuit here has a pushbutton switch hooked up to some power pins (analogue outs) and to digital pin 7, where the test program i am running will turn an LED on and off depending on button presses. in line somewhere is this resistor (10k). ok everything works. i want to know what this resistor is doing here.

but more importantly, is there a general rule of thumb that should be known for applying resistors? to me its just arbitrary right now and i dont know their application.

The simplest explanation I can think of is to consider the resistor as a current limiting device. A bit like a tap (faucet) in a water pipe.

It really depends upon the application as to whether you need a resistor or not. Many devices have input/output resistors built into them in which case an external resistor shouldn't be required.

If you are unable to determine if one should be used, have a look at other peoples example circuits and you may find one similar to your own - did they use a resistor - ?

jack

to me its just arbitrary right now

It can seem like this but it's not. It is like saying it seems arbitrary when cooking if I need to add salt.
For a view on LEDs and resistors see:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html
It goes more into the why resistors are needed with LEDs.
As to the switches, it forces a logic input in to one logic state that can be easily over ridden by the switch forcing it into the other.