Resistor is a kind of electronic component that can be used to limit the current in a circuit. It also shares voltage from the power source. This is a basic thing to know, whether you want to be a rocket scientist, or simply want to learn more about electronics.
You can think of a circuit as a garden pipe. Voltage is the tap, you can twist the tap to adjust the pressure of water source. Current is the amount of water flowing through the pipe. You can adjust it by squeezing the pipe, the harder you squeeze, the less water comes out of the nose. So how hard you squeeze is equivalent to resistance in a circuit.
The unit of voltage, current and resistance is volt(v), ampere(A) and ohm respectively. You can calculate the current in a circuit with this formula:
Where I is the current, V is the total voltage, and R is the total resistance. If the circuit has 5V on it, and 1000 Ohm (1kOhm) in total resistance, the current will be 0.005A (5mA).
To know the resistance of a resistor, check the color strips on them. Check this table to understand the color coding.
When you connect the LEDs to Arduino, there is typically a 220 Ohm resistor in serial connection. The resistor limits the current, so there would not be too much of it flowing through the LED and destroying it. At the mean time, it also limits the brightness of the LED.
When there are multiple resistors in a circuit, they share voltages. Take the potentiometer. One end is connected to 5V, the other end to GND, and the middle pin is connected to an analog in pin. The potentiometer is like 2 changeable resistors, in this case they share a total voltage of 5V, and they share it depending on their resistance. You can use this formula to calculate the voltages:
Where Va is the voltage shared by a, V is total voltage, Ra and Rb are resistance of resistor a and b.
So for example, if you have two resistors that are 400 ohm and 600 ohm respectively, and 5V at the power source. From the formula, you know that they take a voltage of 2V and 3V each.
Analog pins get a value between 0 and 1023 by measuring the voltage at a certain point. To get the voltage at a point, continue with the last example: The power source has 5V, resistor a takes 2V, so at A-in it is 3V. Resistor 2 takes 3V from A-in, leaving 0V at GND, which is how it should be. You know that 5V corresponds to 1023 in analog value, so here there should be around 614 in reading.
To explore some of the applications, check out the project ‘Sequencer’. In this project you want to get a few distinctive analog readings, so the resistors are picked to maximize the differences. Go ahead and do some calculations with the schematics below and resistor values provided. Compare them to the analog values in the sketch to see a connection. Try to add more sequences. Hint: you need to add resistors of different resistances, and it is always good idea to calculate ahead of time.