Making an LED Light up with Raspberry Pi Before Making It Blink

Making an LED Light up with Raspberry Pi Before Making It Blink

Raspberry Pi

Raspberry Pi

Finally, I will try my hand at electronic kits using components! (The above picture shows me playing around with LEDs and three types of resistor.)
I just know that some works with Raspberry Pi involve the use of GPIO. And that’s it! I’m starting from a point where I don’t even know the name of the components.
As I’m still beginning to learn about electronics kits, I want to try making a blinking LED. But before getting it to blink, I’d first like to make the LED light up!

What is GPIO?

GPIO – Wikipedia
GPIO stands for General Purpose Input/Output.
When used for input, it reads digital signals from other parts of the electric circuit, and when used for output, it can control other devices or give notifications of signals.

GPIO – TechTerms
GPIO is a type of pin found on an integrated circuit that does not have a specific function. While most pins have a dedicated purpose, such as sending a signal to a certain component, the function of a GPIO pin is customizable and can be controlled by software.

I mentioned briefly about GPIO in a previous article (Raspberry Pi – Preparation), but I still don’t really understand what is it. Since it “can be used for various purposes depending on its settings,” it would seem that it should work well for working on some hobby projects.
I will figure out the details as I will actually work on it!

Introducing the Components for This Project

When I started this project, I didn’t even know the names of these components. I looked up each one by checking them with pictures from books and websites.
Now, let me introduce the parts used for this project!

Raspberry Pi Breadboard

Picture 1


Breadboard – Wikipedia
A breadboard is a board (base) used for experiments and prototyping of electronic circuits. It’s used in prototyping, experiments, evaluations, and similar purposes.

The term breadboard refers to a part consisting of several holes where other parts can be plugged in to allow for wiring that carries an electronic signal without the need for soldering. Since it’s possible to try many different configurations, it’s great for beginners!


Figure 1

As in Figure 1, the horizontal lines X and Y, and each of the vertical lines from A-E and from F-J, are connected internally. Let’s make sure to do the wiring properly so that the circuit is routed correctly.

Jumper wire

Jumper wire male port female port

Picture 2

These are the cords for the breadboard. Male ports are like those on the blue cord, with metal exposed at the end, and female ports have a square opening at the end like on the green cord. When plugging them into the breadboard, we use the male ports, and when plugging them into the GPIO on the Raspberry Pi, we use the female ports.
The U-shaped parts at the bottom of the picture were made by cutting jumper wire made from hard materials down to the size of the holes in the breadboard. Using these for the breadboard wiring will make things much more tidier.



Picture 3

Resistor – Wikipedia
Resistors are passive elements; they are electronic components used to gain a certain value of electrical resistance.

Resistors are components that serve to adjust the amount of electric current. They are bent into shape before use, as shown on the right side of the picture above.
The strength of resistance is measured in ohms, which use the symbol Ω. Hey, I remember learning about Ohm’s law in junior high school! However, we won’t be using that law right now.

Resistor color code quick guide

Resistance values are determined by the color of the bands printed on the resistor. The colors of the resistor in the picture from left to right are as follows: “red, red, brown, gold” for 220Ω, “brown, black, red, gold” for 1kΩ, and “brown, black, orange, gold” for 10kΩ. Of course, with all those similar colors, it can be pretty hard to tell them apart.



Picture 4

LED (Light Emitting Diode) – Wikipedia

Here is the key element of this project, the LED!
Unlike the resistors, this part has a distinction between positive and negative. Of the two wires like legs, the shorter one is negative. As small as these parts are, it can be hard to tell, but if you look closely from above, you can see that the negative side is shorter.

The Raspberry Pi’s GPIO Terminal

The GPIO terminal on the Raspberry Pi has 40 pins, but how to know which pin is used for what?
Figure 2 shows the circuit diagram taken from the official Model B+ product page.


Figure 2

The numbers are allocated from 1 to 40, and the red lettering on the circuit diagram shows the names of the pins.
Up to number 26, the Model A and Model B are the same.

Pin number

Figure 3

The pin layout for the Model A and Model B are described in the GPIO documentation on the official site. They are color coded and easy to understand.

The GPIO on the Model B+ has 26 pins available to be used, from 2 to 27. The pins are not necessarily arranged in order, so it’s important to check carefully when using them.
Numbers 1 and 17 are the 3.3V power supplies, and numbers 2 and 4 are the 5V power supplies. We can use these when we just want to get power only, without any kind of control.
As described in the notes on the right side of Figure 2, pins 27 (ID_SD) and 28 (ID_SC) cannot be used.
The eight pins numbers that are  omitted (6, 9, 14, 20, 25, 30, 34, and 39) are called GND.

GND (ground) – Wikipedia
Ground refers to connecting the device casing, the neutral point of the electric line, potential line of the electronic device, etc. To the reference point, or to the reference point itself.
It can also be called “earth.”

I think “ground” is easy to understand! It’s the cord attached to consumer electronics that allows electricity to escape. When wiring, we connect it to the negative side. It’s something like a place where electricity can flow away and disappear.

Incidentally, if we want to check the alignment of the actual device with the circuit diagram, it should be aligned vertically with the microSD card slot at the top.

Raspberry Pi GPIO Pin 1

Picture 5

There is also an indicator on the back side. If you look at the back of the board, the pin 1 is soldered in a square shape.


Now, let’s try to do some actual wiring! We will plug in the various components into the breadboard, and the finished product should look something like this.

Raspberry Pi breadboard wiring

Figure 4

Let’s begin by preparing the breadboard. We will place the LED and resistor on the board.
I put the resistor in holes 1 to 4 on the H row, and had the LED follow that, going in holes 4 and 5 on the F row. The resistor has no polarity, so it can be facing either direction. The LED is placed so that the positive side is connected to the resistor.
Parts can be placed in any row from F to J, but the horizontal positions should be arranged so that they connect to the next part.

Next, we will prepare the jumper wires to connect with the Raspberry Pi. The green cord going to hole J-1 is the positive side that connects to the power supply. The yellow cord going to hole J-5 is the negative side that connects to GND (ground).

Breadboard resistor led

Picture 6

This is how my actual board turned out!

The breadboard is now ready, so let’s connect it to the Raspberry Pi!
We connect the negative side jumper wire to GND. This can be connected to any of the eight GND pins (6, 9, 14, 20, 25, 30, 34 or 39). We should connect it to GND first, before connecting to the power supply.
This time, we only want to light up the LED, so we will directly connect the positive side to the power supply. If the electric current is too strong, it could possibly damage the LED, so I am using the 3.3V power supply on pin 1.

Once we connect the jumper wire, the current flows through…

Breadboard resistor led light up

Picture 7

The LED lights up without any problems!
It lit up as soon as I touched the jumper wire to the GPIO, so we must be careful not to touch it to the wrong place by mistake.

Let’s Make it Blink!

Next, let’s try controlling the LED from the Raspberry Pi side!
We will leave the breadboard as it is, and move the positive side wire on the GPIO from the 3.3V power supply on pin 1 to the GPIO2 pin one spot over on pin 3.
Wait a minute?! It’s still shining for some reasons. It appears that this pin allows current to pass normally by default.

So let’s enter some commands!
First, we will need to prepare the GPIO port for use.

The “echo” command is a command that writes to a file. The syntax is “(value to be written) > (filename).” Since we will be using GPIO2 this time, I specify the value “2.”
Incidentally, I was able to visually confirm the virtual files on the Raspberry Pi. If you actually browse to “/sys/class/gpio” in the file explorer, you can see that there is a virtual folder named “gpio2.”

Raspberry Pi GPIO

Figure 5

And, if we look inside the gpio2 folder…

Raspberry Pi GPIO2

Figure 6

… it looks like this. We can control the GPIO by writing to these files. It’s easy to grasp when we can see it like this with our own eyes!
Next, we will designate whether “gpio2” is to perform input or output. The input/output setting is done in the “direction” file.

This time, we are transmitting a signal, which is output, so we will use the “out” setting.
(When I entered the command, the LED went out! It appears that it switched over to allow individual control.)

The output value settings are done in the “value” file.

If we set the value to “1,” current will flow and the LED will light up. We can turn off the LED by using a value of “0” to cut off the current. You can confirm that the value has been rewritten by opening the “value” file in a text editor.

When finished, use this command to stop using the GPIO. The opposite of the “export” command is “unexport.” When we execute this command, the gpio2 folder will get deleted.

Raspberry Pi LXTerminal

Figure 7

Everything up to this point is the full sequence. We have successfully controlled the LED from the Raspberry Pi!
It’s a simple and easy to follow process that only involves rewriting the contents of four files: “export,” “direction,” “value,” and “unexport.” The virtual files could be directly viewed, so I was able to check the control mechanisms as I went along.


I managed to make the LED light up, and my first electronic kits project was a success!
Wiring the breadboard was like doing a puzzle, so I had fun playing around with it. It was also interesting to see the results of my commands take place physically in the real world in the form of a shining LED! I am now even more interested in electronic kits!

For my next article (#10), I will finally get around to making that LED blink!
To make an LED blink, will I have to… Use a program? What kind of language and tools will I need to use? Follow me as I continue to learn and move step by step through this project!