The maker toolkit has a core selection of essential maker tools. The tools that we can’t do any work without. Breadboards, soldering irons, LEDs are important, but resistors are the tiny components that projects depend on.
No matter what board we choose, be it Raspberry Pi, Raspberry Pi Pico or Arduino, we need resistors to protect our LEDs, divide voltages and provide precise values for our circuits. But what do they do, why do we need them and how can we make sure we have the correct value? For that we need to do a little math, and consult a few datasheets.
In this reference we will explain what resistors are, what they do and tell you how to pick the correct resistor for your next project.
What are Resistors?
Resistors are components which introduce electrical resistance in a circuit. Typically they are used to reduce the current flow in a circuit, for example when used with LEDs they stop the LED from consuming too much current.
An LED without a resistor will burn itself out very quickly. Resistors can also be used to create voltage potential dividers, useful circuits that will reduce the voltage in a circuit. Every maker will have some resistors in their kits. They come in bandolier strips and can be bought in singular packs or in their thousands.
Why Do We Need Resistors?
The most basic use of resistors is to stop a component from consuming too much current. Take for example an LED (Light Emitting Diode). LEDs are designed to pass current in one direction and produce a small amount of light as they operate. If we give LEDs as much current as they want, the LED will light brightly but soon burn out. In some cases we can give it too much current at once, causing the LED to “pop” and then die.
We can use the following calculation to determine the exact resistor value.
R is the resistor value, Vs is the supply voltage, Vf is the forward voltage (the amount component needs), and If is the forward current.
Let’s put this into practice. We have a blue LED connected to a 5V supply. The forward voltage of the LED is 3.2V and the required current is around 10mA. So the calculation looks like this.
This means that the value of R is 180 Ohms. In the standard series of resistors we can use this exact value or we can choose a 150 or 220 Ohm resistor instead. For basic tasks, the exact value isn’t essential but when designing circuits for professional / industrial or high precision devices you will need to use the exact values. The exact values can be found in the components datasheet or on the product page from your chosen store.
For most hobbyist / maker applications we can choose the nearest value that we have. We often favor a 220 / 330 Ohm resistor for our LEDs.
Pull up or Pull down
Resistors can also be used to pull up or pull down a GPIO pin. A pull up resistor will pull a pin high by connecting a voltage supply to a pin. A pull down resistor will pull a pin down to GND. We used a 10K Ohm resistor with a DHT22 temperature sensor to pull the data pin high using the 3.3V supply.
Resistors can also be used to drop voltages from one level to another. This is called a voltage divider and it is commonly used in potentiometers to vary the voltage.
To create a voltage divider we need to use this equation.
Vout is the voltage that we want.
Vin is the input voltage.
R1 is the first resistor’s value.
R2 is the second resistor’s value.
So, for our voltage divider we want to convert the 5V input voltage to around 3.3V. This process is commonly used when we need to change the logic voltage of a component, for example the HC-SR04. The HC-SR04 ultrasonic distance sensor originally used 5V logic, and so the echo pin, which activates when sound bounces off an object, will send 5V to the GPIO.
For an Arduino, this is ok. For a Raspberry Pi, it can damage the pin, or even the Pi. We’re using two resistors, R1 a 1K Ohm resistor (top) and R2 a 2.2K Ohm resistor (bottom) to create a voltage divider. The legs of R1 and R2 go into the same row of the breadboard. Into R1 we supply 5V and into R2 we connect to GND. Where the legs of R1 and R2 meet is the output voltage, which should be 3.4375V, well within the tolerance of the 3.3V GPIO.
The calculation works by adding R1 and R2 together (1000 + 2200 = 3200) then we divide the value of R2 by this (2200 / 3200 = 0.6875) and lastly we multiply by the input voltage (5 8 0.6875 = 3.4375V).
There’s still lots more to see: How To Use Resistors in a Project