In our previous article, we explained how to make LEDs twinkle using Arduino with an L circuit. I hope everybody had a chance to try it. That was a very basic circuit. This time, I would like to dive even further into the world of Arduino, starting with the LED and moving to various electronic components.
In the last article, as shown in the picture, we directly plugged an LED into Arduino to make it light up. For those of you who have a little experience with electronic circuits, you probably already knew this, but actually, this sends more current through the LED than it should. To understand why, let’s learn a little bit more about a basic circuit.
When drawn out, the circuit would look like this. The current flows from the positive pin 13, through the LED and into the negative pin, GND.
The keyword here is current. The most basic part of an electrical circuit is voltage and current.
What is this voltage and current we hear so much about when discussing electronic circuits? We all studied Ohm’s Law and other things in science class in elementary and junior high school. Let’s look back on those dear days and recap what we learned. Probably the most common analogy used to describe current and voltage is to compare it to water flowing through a pipe.
Using the previous circuit diagram, the water begins at the positive pin 13 (source) passes through the LED and flows downstream to the negative.
I’m sure some of you have questions. As seen in the circuit diagram, we discussed earlier, the flow is from the positive to the negative terminals, but looking at the pipe diagram, it is not easy to see the direction of the flow of water. Let’s look at the concepts we learned in junior high school a little differently.
The water flows to GND, called ground, which is shown as the earth or solid ground. Water comes out of the pipe, flows through the electrical components, like the LED, and eventually flows out into the soil. The GND is the sewage line so to speak. Essentially, electronic circuit design is confirming that the current and voltage flow from positive in order to power the electrical components and finally ends up at the GND.
So, rather than a circuit diagram described above that we used in junior high school, I am going to use the diagram below where the GND is at the bottom to design a circuit.
Although it may be hard to grasp this concept by just reading the explanation, don’t worry, as it will become apparent as you begin to assemble circuits.
If you want a more in-depth explanation, put the search terms’ current, voltage or current, voltage flow in the search engine of your choice.
Let’s go back to talking about Arduino. We have inserted the LED into the Arduino circuit, but let’s consider what kind of circuit design do we need exactly to properly light the LED (actually, it is difficult to define what we mean properly).
What we need to properly light the LED is a resistor. I believe we have all been exposed to resistors in our junior high school classes. Just as its name suggests, a resistor plays the role to suppress or inhibit the electrical flow. Going back to the water pipe example, it would be like a stone or other obstruction in the pipe causing the water flow to decrease.
In order to illuminate a LED, a suitable voltage (rated voltage) and current (rated current) are written on its side. Resistors must be added to the circuit, to meet the rated voltage of the LED.
Our LED is rated at 2 volts with a current of 20 mA, so we use that to calculate the required resistance.
First, the Arduino UNO we are using this time is specified with an operating voltage of 5V.
To determine the necessary current and resistance, we have to use what we all learned long ago, OhmÅfs law.
1 |
<span style="color: #ffffff;">Current I (A) = voltage E (V) / resistance R (Ω)</span> |
Here, the output voltage of the Arduino is 5V, and since the LED only needs 2V is rated at a voltage of 2V, we need to add resistance to reduce the voltage as follows: 5V-2V = 3V.
1 |
<span style="color: #ffffff;">I (A) = 3V/R (Ω)</span> |
Next, since the LED wants a current of 20 mA, putting that into the equation determines the resistance value.
1 |
<span style="color: #ffffff;">0.02A = 3V/R(Ω)</span> |
1 |
<span style="color: #ffffff;">R(Ω) = 150</span> |
With that said, the resistance value required to illuminate the LED is 150É∂, so we will add that resistor to the circuit.
So, we build the circuit in Arduino. This time, since the electronic components we will be adding are an LED and a resistor, we will use what is called a breadboard. It’s a tool that makes it easy to build an electric circuit without using solder. A breadboard has various lines on the back connecting points on the board making it possible build a circuit.
(Left) Arduino and breadboard – (Right) back of the breadboard
※ There are various sizes and types of breadboards. As the circuit we are making does not have many components, so a small breadboard would not be a problem. But I recommend you getting a bigger board from the start, so when we do start making larger circuits you will still be able to use it.
Well, we will build our circuit with the LED and resistor on the breadboard.
Please wire your circuit, using the following diagram as a reference. If you wired your circuit correctly, the LED should be illuminated. You can see that the brightness is less than when we wired it directly to the circuit.
Now that you successfully wired your circuit, add a few more resistors. Doing this weakens the current through the LED, and you will notice the emitting light getting darker.
This time, we discussed how to use resistors to limit the voltage and current through our electronic components.
So far we have only used the Arduino as a power source, but next time we will have fun changing the parameters of the program itself to control the circuits.
1 2 3 4 5 6 7 8 9 10 11 |
int led = 13; void setup() { pinMode(led, OUTPUT); } void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); } |