How To: Control LED using Raspberry PI GPIO

In this post I will take you through the fairly simple task of getting your Raspberry PI to control an LED via the GPIO interface, the task is simple however it lays a great foundation of knowledge for any further projects where you want to interface with an external electronic device.

So the first step is to install some software on to the Raspberry PI operating system via terminal or a remote SSH session. We actually want to install “wiringPi” however to do that we are going to use the very popular version control tool “git”, which should explain the following commands.How To Control LED using Raspberry PI GPIO

1. Software Setup

First we will install the core software required for git to work:

1
sudo apt-get install git-core

Next it’s aways best to ensure that our device is on the lastest version of software, so we will do an update and upgrade, depending on how long until you last did this it could take a while, coffee anyone?

1
2
sudo apt-get update
sudo apt-get upgrade

Ok so your back after the software update, now we are going to download the latest release of wiringPi;

1
git clone git://git.drogon.net/wiringPi

Now go into the directory and just double check with the pull command that you have all the required files.

1
2
cd wiringPi
git pull origin

Now time to build the software with a command that’s fairly easy to remember:

1
./build
How To Control LED using Raspberry PI GPIO schematic
Physical

For the physical setup you will need an LED of your preferred colour, a small 270 ohm resistor and some wire to connect everything together. I would recommend using a breadboard as well it makes all this cabling and prototyping far easier to setup and tweak.

Below is a very simple diagram on how to setup your circuit.

 

For more detail: How To: Control LED using Raspberry PI GPIO


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top