First off I'm no expert but I have gotten a bit wiser about what resistors are good for and how to find the right ones for a specific purpose. I will tell you about two important uses of resistors.
Limiting current so things don't burn
Let's say you just bought this amazing new component called an LED that you want to use in your robot. You plug it into your circuit and turn the power on. Poof! Smoke and fire everywhere (ok that's maybe a bit over the top, but you get the idea). What happened?
Well the LED is a component that has very little resistance so a lot of current can flow through it even if the applied voltage is small - it is almost like a short-circuit. The great amount of current will destroy the LED (maybe because of the heat or something - I don't really know why) and you will generally not be very happy with the result.
In order for the LED not to burn you have to limit the amount of current that is supplied to it and this is where resistors come into the picture.
Resistors are components that obey Ohm's law:
U = R * I
Which says that the voltage-drop U across a resistor is equal to the resistance R of the resistor times the current flowing through the resistor.
If you put a resistor in series with the LED (either before or after the LED) you will limit the current going through the LED to the amount of current going through the resistor (which can be calculated as I = U/R where U is the supply voltage to the circuit minus the voltage drop over the LED - you can just use the supply voltage as U since it will only result in less current than you expected and not the other way around).
If you happen to buy a package with assorted LEDs like I did you can check the package to see what the maximum amount of current they should have is - on the ones I bought it said 50 mA maximum but standard LEDs
are nicely lit at around 15 mA so if you have a voltage supply of 5 V a resistor with a resistance of 330 ohms should do nicely.
Generally you should read the datasheet for your components and check what kind of values it can cope with.
Measuring voltage through voltage dividers
This is a very very powerful and common construction. It enables you to measure a voltage - usually through an analog-to-digital converter (ADC for short).
The setup is two resistors with resistances R1 and R2 in series so that the resistor with resistance R1 is connected to positive power Vin (let's say it's 5V) and the resistor with resistance R2 is connected to ground. At the point where the resistors are connected to each other we connect the ADC-pin. The voltage Vout at this pin is then
Vout = Vin * R2 / (R1 + R2)
This might seem like an odd thing to do, but if the resistor with resistance R1 is a variable resistor, like for example a light dependent resistor that has low resistance when light is shining on it and high resistance when it is not, then Vout will vary with the amount of light shining on the resistor and this can be measured by the ADC-pin and used as a number value in your micro-controller.
I know this is perhaps not the best explanation in the world :-) and it doesn't help that there are no pictures or figures, but I hope you got a bit of insight into why we need resistors. Just trying to help my fellow robo-builder :-)
My advice for beginners going to buy resistors is to buy packages with assorted resistors like the Velleman set of 610 resistors which have 10 resistors of each of the values in the E12 series (61 different values) and when you have built a couple of circuits you will likely know what types of values you will typically use and then you can order those specific values in packages of 100 or 1000 resistors per value.
TigPT kindly provided me with a link to a color code table for resistor values - you should print it out and have it hanging at your workbench :-)
- Jimmy