DEV Community

Cover image for Hello world in electornics
Krisztián Maurer
Krisztián Maurer

Posted on

Hello world in electornics

I started to get interested in hobby electronics alongside programming a while ago. I think the two fields are similar and exciting projects can be created by combining them.

Are you interested in both electronics and programming? Do you want to create exciting projects that combine the two fields? In this article, I will show you how to light up an LED / LED strip, the "Hello World" of electronics, and explain the importance of resistors and voltage, paralell vs series circuits, how to put them together, howto check the components datasheet. Before someone start programming microcontrollers I think thies thing a must know.

What is needed for this project:

  • LEDs
  • Resistors
  • Power supply, Breadboard, jumping cables

Here is the circuit diagram that we will make:

Maurer Krisztián

You may have the following question:
Why do you need a resistor for the LED? and what does its value depend on?

We have to look at the LED current and voltage requirements

Let's say this is a LED 5 mm Red, if we take a look at its data sheet (you can quickly find a PDF description online, just search for the type), we see this about optimal operation:

Maurer Krisztián

I would be interested in how much Voltage is required to operate the LED optimaly. This is the forward voltage V(f).

The forward voltage is the amount of voltage needed to get current to flow across a diode. This is important to know because if you are trying to get a signal through a diode that is less than the forward voltage, you will be disappointed.
The amount of light emitted by an LED is directly proportional to the forward current flowing through it, up to a certain point.

The optimal voltage in my case is between 2V - 2.8V, so if we allow more than 2.8V to pass through, it is likely to burn out th LED and we will have to throw it away. We adjust the voltage up to 2.8V to control the brightness of the LED.

Let's say we have a 9V battery that we want to operate from. The voltage that the led receives should be somehow limited, this is where the Ohm's law and resistors can help us.

For Current, we can also find on the datasheet that I(f)=20mA (milliamer) which is 0.02A (Ampere).

The forward current of a LED is the electrical current that flows through the LED when it is in forward bias. In other words, it is the current that is required to make the LED emit light.

Maurer Krisztián

Ohm's law: I (Current) = V (Voltage) / R (Resistance)

This doesn't really say much at first. Let's see how we can apply it and maybe it will be clearer.

We have a 9V power source and the LED requires 2V, which means that the resistor needs to consume 7V so that the LED can get 2V.

What will be the value of Resistor?

R = V(s) - V(f) / I(f)
R = 7V (drop) / 0.02 I (LED I(f))
R = 350 Ohm

Let's look at the max as well

R = (9V - 2.8V) / 0.02I = 310 Ohm

so that we stay in the 2 - 2.8 volt range, a resistor between 310 Ohm and 350 Ohm is needed in this case.

Our circuit is now functional and the LED will not explode.

Maurer Krisztián

Lets go, order the components

  • power supply - 9V battery ~4$ or use other power source e.g usb breadboard see below

  • Breadboard + (Power Supply) + Jump Cable Wires ~15$ (essecial for every prototypeing)

Maurer Krisztián

  • 1 LED - ~0,1$ (before buying check the datasheet)

  • 2 resistor ~ 0,03$ (A smaller one and a larger one, based on what kind of power source and led you have)

since the LEDs, resistors, cables are so cheap and will be useful in almost every project, it is worth buying in a kit.

To have a basic starter kit that you can use for future projects, budget around $16-$25

Circuit build:

  • Breadbord

Maurer Krisztián

To connect components on a breadboard, simply insert the leads of the component into the holes on the board. Each row of holes is connected internally, so you can connect components by inserting them into different holes on the same row or by connecting them across rows using jumper wires. Jumper wires are short wires with connectors on each end that can be used to connect components on different rows or columns of the breadboard.

It's good to have a multimeter because usually, the values don't exactly match what's written on paper. The power supply voltage should be 5V but it's only 4.49V, and the resistor also deviates by 1-3-5%, but this won't be a problem if we calculate the optimal value, because it usually falls within that range.

Maurer Krisztián

Maurer Krisztián

What if we want to make a seriez of led? Let's put 2 led in seriez.

Maurer Krisztián

Something is wrong the led bearly light up, and if I more than 2 its not working.

Explonation:

  • In a series circuit, the voltage is divided among the components, meaning that the voltage drops across each component. But, the current remains the same throughout the circuit because there is only one path for the current to flow. Therefore, the voltage drop is V(led1) + V(led2) + V(resitor). So if we want to make 10 LED circuit in series that means we need at least 10 * (LED)V voltage. In my case around 20V.

but we can do it with paralell with the same volate.

  • In a parallel circuit, each component has the same voltage across it. This means that the total voltage of the circuit is equal to the voltage across each component. However, the current is divided among the branches of the circuit. Each branch of the circuit receives a fraction of the total current, and the sum of the currents in each branch is equal to the total current of the circuit.

so if we want to create a paralell 10 LED or 100 LED circut the voltage requirement is remain the same. But the Current requiroment add up. 100 LED needs 20mA * 100Led = 2000mA, If the power supply not capable giveing this amount of current the circit will not work.

Maurer Krisztián

Maurer Krisztián

Congratulations, you are now an electrical engineer! 😀

Top comments (0)