Raspberry Pi of Goemon

Raspberry Pi3 learning blog

Beginner Electric work

Blink LED on Raspberry Pi 3

Post:23/09/2016 Update:

Blink LED is a very first step for beginners. You can learn how to connect each electric component and control it with minimum numbers of components and a small chunk of code.

Table of contents

  1. GPIO pin layout
  2. Hardware setup
  3. Code
  4. Result
  5. Reference

The necessary parts and tools are here. The selection of resistor depends on LED’s Vf (forward voltage). You can usually find the value on its specification/catalog.

Name Qty
Resistor 1 330 Ω
Red LED 1 Vf = 2.0 V
Breadboard 1
Breadboard jumper wire (male-female) 2
Nippers 1
Sponsored Link

1. GPIO pin layout

GPIO (General Purpose Input/Output)  is an interface for Raspberry Pi to be connected with any external devices. Raspberry Pi 3 has 40 pins. Each pin is assigned different function. Wrong connection could cause failure. Thus you have to be careful when you connect your device with GPIO. The pin layout is not printed on the Raspberry Pi board. So this will be handy when you do electric works with Raspberry Pi 3.


2. Hardware setup

There are several ways to blink LED. Here is how I did. I cut the wire of the parts because they were a bit long to fit my breadboard. You have to be careful when you cut the wire of LED. Anode wire is longer than cathode. If you cut them in the same length, you will be confused. When you see this map, you may notice two important points: GPIO 25 and 330 Ω.


  • GPIO 25

While LED cathode is connected to PIN#6 (GND), LED anode is connected to PIN#22 (GPIO 25). GPIO 25 is connected to SoC(BCM2837). SoC can control the output voltage of GPIO 25, either HIGH or LOW. It’s 3.3 V when it’s HIGH, while it’s 0 V when it’s LOW. You can put voltage on the anode by writing some codes.

  • 330 Ω

This value is decided based on the forward voltage (Vf) of LED. It’s 2.0 V on my LED when the current is 20 mA. It could be broken if you put voltage larger than Vf. Thus you need to put a resistor to decrease the voltage. You can know how I selected a resistor below.

When HIGH:

GND-GPIO 25 = 3.3 V

Vr (voltage put on a resistor): 1.3 V (3.3 – Vf: where Vf = 2.0 V)

When current flows in the circuit is 20 mA

R (resistance value) : 1.3/0.02 = 65  Ω

Thus, as far as you use a resistor larger than 65 Ω, it should be okay! But if your resistor is too large, LED will be very dark. I used 330 Ω and set up like this.


3. Code

Here is the code. I use Python 2.7.12. You can run the program simply “Run”>”Run Module” from the editor cab stop it by pressing “Ctrl+C”.

4. Result

This is my first work. It’s simple and easy but I still learned how I integrated H/W and S/W. I just needed to be careful when I connect the wired with GPIO to avoid wrong connection.


5. Reference

I referred a Japanese book. I’m afraid that most of people cannot read it. But you can still find the H/W setup in it.



Sponsored Link

Sponsored Link

-Beginner, Electric work
-, , ,

Related Posts


How to deal with switch bounce

Today, I will deal with switch bounce. Then I will toggle the switch to control LED (OFF/ON). Now let’s start! Table of contents Switch bounce Bounce time Code Result Reference Sponsored Link 1. Switch bounce Switch bounce is a phenomenon that occurs when you use a physical contact switch such as a tact switch. When you push a switch, you may think it gets immediately ON. However, that’s not correct in the micro-scale world. When a switch is toggled, metal contacts of a switch come together and close. During this time, metal contacts are bouncing and that causes noise. This …


Utilize an internal pull-down resister

In the previous post, I checked how a pull-down resister functioned. When it’s there the system worked as expected. However once it’s taken off, then LED became unstable. Actually, Raspberry Pi 3 contains an internal pull-down resister and you can enable it by coding. Today, I’m gonna show you how you can enable an internal resister and how it works. Don’t worry, it’s very simple 🙂


Install Raspbian on Raspberry Pi 3

The very first thing you have to do is to install OS on your Raspberry Pi. Today I install Raspbian on which various programs for learning are available. Table of contents Format SD card Download NOOBS Hardware setup Raspbian installation & setting Connect to Internet OS update What you need Micro SD card (larger than 8GB) *class 10 is recommended PC connected to Internet Mouse Keyboard Micro USB power supply PC monitor (HDMI or DVI-D) Monitor cable (monitor <=> Raspberry Pi 3) Sponsored Link 1. Format SD card If your SD card is new, you can skip this step. Mine …


How to use your tablet/smartphone as screen

Raspberry Pi is small and portable in itself. Also you can easily carry a charger for it. However, you are unlikely to carry a screen with you. It’ll be super convenient if you can use your smartphone/tablet as screen for Raspberry Pi. Today is about how to make your tablet/smartphone screen for Raspberry Pi. Please note that this method is possible only when both of your mobile devices and Raspberry Pi are connected to a same network. Table of contents Check Raspberry Pi IP address Set up SSH Install & set up VNC server on Raspberry Pi Install & set up …


Control LED by tact switch

In a previous post, how to blink LED with Raspberry Pi 3 was introduced (Blink LED on Raspberry Pi 3 ). In this work, I just got an “output” from Raspberry Pi. Today, I will send an “input” to Raspberry Pi by using a tact switch.By sending an input, you can get Raspberry Pi to send an output. With this work, you can turn on/off your LED with a tact switch. Table of contents Tact switch Hardware setup Code Result Reference What you need You may want a nipper to cut the legs of resister if they are long. Name Qty Resistor …