Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Programming of Raspberry Pi To Control LEDs Attached To The GPIO Pins

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Programming of Raspberry Pi To Control LEDs Attached To The GPIO Pins

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Priyanka Dubey, 2022, 10:3

ISSN (Online): 2348-4098


ISSN (Print): 2395-4752

Raspberry Pi-GPIO Basics with LED Light


Dr. Priyanka Dubey
Dept. of Computer Science
Amity University,
Manesar, Haryana, India

Abstract- These days computer is the basic need for every people in every field across the world.

Raspberry pi is small size or credit card sized computer. The Raspberry Pi is a small computer that can

do lots of things. You plug it into a monitor and attach a keyboard and mouse. There is a Broadcom
BCM2835 SOC to integrate major functional element into single chip. We can control any hardware

equipment through Raspberry Pi by using GPIO pins. Python programming languages are preferred to

program the Raspberry Pi. It allows monitoring and controlling of hardware equipment. There are
three series of Raspberry Pi, and several generations of each have been released. Raspberry Pi SBCs

feature a Broadcom system on a chip (SoC) with an integrated ARM-compatible central processing unit
(CPU) And on-chip graphics processing unit (GPU), while Raspberry PI Pico has a RP2040 system on

chip with an integrated ARM-compatible central processing unit (CPU)). Raspberry pi is a series of

small single-board computers developed in the United Kingdom by the Raspberry Pi foundation in
association with Broadcom. The Raspberry pi project originally learned towards the promotion of

teaching basic computer in schools and in developing countries. This paper explains the Raspberry Pi

with the explanation of GPIO pins, and through it showing the working or blinking of LED light. The
main task of doing it is that through it we can make home automation project, by which home smart

gadgets can be controlled from anywhere with the help of relay. The paper mainly emphasis on the

home automation project with the help of LED light and the coding is used to accomplish the task. The
Raspberry Pi has two zones of GPIO pins, which are the connections between the Raspberry Pi, and the

real world. Output pins are like switches that the Raspberry Pi can turn on and off. It can also send a
signal to another device.

Keywords- Raspberry Pi, Home automation, LED, GPIO pins, Processor.

I. INTRODUCTION It can be plugged into your TV and a keyboard and


can be used for many of the things that your average
The raspberry Pi Foundation is a British charity and desktop does - spreadsheets, word-processing,
company founded in 2009 to promote the study of games and it also plays high-definition video. The
basic computer science in schools and is responsible Raspberry Pi is a fully featured microcomputer
for developing the Raspberry Pi singe-board squashed onto a circuit board measuring
computers. approximately 9cm x 5.5cm.

The Raspberry Pi is a tiny and affordable computer The Raspberry Pi has a Broadcom BCM2835 system
that you can use to learn programming through fun, on a chip (SoC), which includes an ARM1176JZF-S
practical project. The Raspberry Pi is a credit-card 700 MHz processor •It has Video Core IV GPU •
sized computer originally shipped with 256 megabytes of RAM, later

© 2022 Priyanka Dubey. This is an Open Access article distributed under the terms of the Creative Commons Attribution License
(http://creativecommons.org/licenses/by/4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the
original work is properly credited.
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

upgraded to 512MB. • It does not include a built-in ensure every child has access to learning about
hard disk but uses an SD card for booting and long- computing. Similarly, Raspberry Jams are Raspberry
term storage. Pi-focused events for people of all ages to come
together to learn about Raspberry Pi and share ideas
It has 10/100 Base T Ethernet socket, HDMI socket, and projects and trains educators who can guide
USB 2.0 socket, RCA video socket, SD card socket, other people to learn.
Powered from microUSB socket • 3.5mm audio out
jack • Header footprint for camera connection is What Raspberry Pi models have been released?
there in Raspberry Pi There have been many generations of the Raspberry
Pi line: from Pi 1 to 4, and even a Pi 400. There has
generally been a Model A and a Model B of most
generations. Model A has been a less expensive
variant and tends to have reduced RAM and fewer
ports (such as USB and Ethernet). The Pi Zero is a
spinoff of the original (Pi 1) generation, made even
smaller and cheaper.

Here's the lineup so far:


 Pi 1 Model B (2012)
 Pi 1 Model A (2013)
 Pi 1 Model B+ (2014)
 Pi 1 Model A+ (2014)
 Pi 2 Model B (2015)
 Pi Zero (2015)
 Pi 3 Model B (2016)
 Pi Zero W (2017)
 Pi 3 Model B+ (2018)
 Pi 3 Model A+ (2019)
Fig 1. Raspberry Pi.
 Pi 4 Model A (2019)
 Pi 4 Model B (2020)
All over the world, people use the Raspberry Pi to
 Pi 400 (2021)
learn programming skills, build hardware projects, do
home automation, implement Kubernetes, and edge
computing, and even use them in industrial II. RASPBERRY PI OPEN SOURCE
applications.
The Raspberry Pi operates in the open-source
The Raspberry Pi Foundation works to put the power ecosystem: it runs Linux (a variety of distributions),
of computing and digital making into the hands of and its main supported operating system, Pi OS, is
people all over the world. It does this by providing open source and runs a suite of open-source
low-cost, high-performance computers that people software. The Raspberry Pi Foundation contributes to
use to learn, solve problems, and have fun. It the Linux kernel and various other open-source
provides outreach and education to help more projects as well as releasing much of its own
people access computing and digital making—it software as open source.
develops free resources to help people learn about
computing and making things with computers Code Some people buy a Raspberry Pi to learn to code,
Club and CoderDojo are part of the Raspberry Pi and people who can already code use the Pi to learn
Foundation, although these programs are platform- to code electronics for physical projects. The
independent (they're not tied to Raspberry Pi Raspberry Pi can open opportunities for you to
hardware). create your own home automation projects, which is
popular among people in the open-source
The Raspberry Pi Foundation promotes these clubs community because it puts you in control, rather
and helps grow the network around the world to than using a proprietary closed system.
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

III. WHAT RASPBERRY PI WORKS

Fig 5. Voice-Activated Coffee Machine

Fig 2. Connections with Raspberry Pi.

IV. APPLICATIONS:

1. Can be used for making supercomputer.

Fig 6. Raspberry Pi Dynamic Bike Headlight


Prototype.

V. GENERATIONS OF RASPBERRY PI

The first generation (Raspberry Pi 1 Model B) was


released in February 2012. It was followed by a
simpler and inexpensive model Model A.
• In 2014, the foundation released a board with an
improved design in Raspberry Pi 1 Model B+.
These boards are approximately credit-card sized
Fig 3. Raspberry Pi in Supercomputer.
and represent the standard mainline form-
factor.
2. Raspberry Pi Medical Device Input Shield.
• Improved A+ and B+ models were released a
year later. A "compute module" was released in
April 2014 for embedded applications, and a
Raspberry Pi Zero with smaller size and reduced
input/output (I/O) and general-purpose
input/output (GPIO) capabilities was released in
November 2015 for US$5.

1. The Timeline:
• The Raspberry Pi 2 which added more RAM was
released in February 2015.
• Raspberry Pi 3 Model B released in February
2016, is bundled with on-board WiFi, Bluetooth
and USB boot capabilities.
Fig 4. Solar Raspberry Pi Power Pack.
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

• As of January 2017, Raspberry Pi 3 Model B is the turn on or off (input) or that the Pi can turn on or off
newest mainline Raspberry Pi. (output).
• Raspberry Pi boards are priced between US$5–
35. One powerful feature of the Raspberry Pi is the row
• As of 28 February 2017, the Raspberry Pi Zero W of GPIO pins along the top edge of the board. GPIO
was launched, which is identical to the Raspberry stands for General-Purpose Input/Output. These pins
Pi Zero, but has the Wi-Fi and Bluetooth are a physical interface between the Raspberry Pi and
functionality of the Raspberry Pi 3 for US$10. the outside world. At the simplest level, you can
think of them as switches that you can turn on or off
2. Features: (input) or that the Pi can turn on or off (output).
• All models feature a Broadcom system on a
chip (SoC), which includes an ARM compatible The GPIO pins allow the Raspberry Pi to control and
central processing unit (CPU) and an on-chip monitor the outside world by being connected to
graphics processing unit (GPU, a Video Core IV). electronic circuits. The Pi is able to control LEDs,
• CPU speed ranges from 700 MHz to 1.2 GHz turning them on or off, run motors, and many other
for the Pi 3 and on board memory range from things. It’s also able to detect whether a switch has
256 MB to 1 GB RAM. been pressed, the temperature, and light. We refer to
• Secure Digital (SD) cards are used to store this as physical computing.
the operating system and program memory in
either the SDHC or Micro SDHC sizes. There are 40 pins on the Raspberry Pi (26 pins on
• Most boards have between one and four USB early models), and they provide various different
slots, HDMI, and composite video output, and a functions.
3.5 mm phono jack for audio.
• Lower-level output is provided by a number of If you have a RasPiO pin label, it can help to identify
GPIO pins which support common protocols like what each pin is used for. Make sure your pin label is
I²C. placed with the keyring hole facing the USB ports,
• The B-models have an 8P8C Ethernet port and pointed outwards.
the Pi 3 and Pi Zero W have on board Wi-Fi
802.11n and Bluetooth.

3. Operating System:
The Foundation provides Raspbian, a Debian based
Linux distribution for download, as well as third party
Ubuntu, Windows 10 IOT Core, RISC OS, and
specialized media centre distributions.
• It promotes Python and Scratch as the
main programming language, with support for
many other languages.
• The default firmware is closed source, while Fig 7. GPIO pin numbering.
an unofficial open source is available.
When programming the GPIO pins, there are two
different ways to refer to them: GPIO numbering and
VI. GPIO PINS IN RASPBERRY PI physical numbering. Throughout this course (and in
all our resources) we will refer to the pins using the
A standard interface for connecting a single-board GPIO numbering scheme. These are the GPIO pins as
computer or microprocessor to other components is the computer sees them.
through General-Purpose Input/Output (GPIO) pins.
GPIO stands for General-Purpose Input/Output. The numbering of the GPIO pins is not in numerical
order, instead relating to the numbering on the CPU
These pins are a physical interface between the of the Raspberry Pi, so there is no easy way to
Raspberry Pi and the outside world. At the simplest remember them. However, you can use a reference
level, you can think of them as switches that you can board that fits over the pins, a printed reference (like
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

the image above), or a website guide to the GPIO speed in which the devices to transfer data to
pins to help you. each other.
• UART pins – UART stands for universal
1. Voltages: asynchronous receiver-transmitter, which is a
The voltage of a pin is labeled on the reference physical circuit designed to send and receive
guide. There are two 5V pins and two 3V3 pins, as data.
well as a number of ground pins (0V), which are • PWM pins – PWM means “pulse width
unconfigurable. The remaining pins are all general- modulation,” which is a communication protocol
purpose 3V3 pins, meaning that the outputs are set best used with stuff that moves and lights up:
to 3.3 volts and the inputs are tolerant of 3.3 volts. motors, LEDs, and so on.
• I2C pins – I2C is short for inter-integrated circuit
A GPIO pin designated as an output pin can be set to (two “inters” or Squared). It works similarly to SPI,
high (3.3V) or low (0V). Components are usually but it doesn’t force you to use nearly so many
attached so that setting the output to high will allow pins.
current to flow to them, while setting the output to
low won’t. GPIO are your standard pins that simply be used to
turn devices on and off. For example, a LED.
A GPIO pin that is designated as an input will allow a • I2C (Inter-Integrated Circuit) pins allow you to
signal to be received by the Raspberry Pi. The connect and talk to hardware modules that
threshold between a high and a low signal is around support this protocol (I2C Protocol). This will
1.8V. A voltage between 1.8V and 3.3V will be read typically take up 2 pins.
by the Raspberry Pi as high; anything lower than 1.8V  SPI (Serial Peripheral Interface Bus) pins can be
will be read as low. Do not allow an input voltage used to connect and talk to SPI devices. Pretty
above 3.3V, or else you will fry your Pi! much the same as I2C but makes use of a
different protocol.
The GPIO header provides the following power and  UART (Universal asynchronous receiver/
interface options: transmitter) are the serial pins used to
• 3.3V (on 2 pins) communicate with other devices.
• 5V (on 2 pins)  DNC stands for do not connect, this is self-
• Ground (on 8 pins) explanatory.
• General purpose input and output  The power pins pull power directly from the
• PWM (pulse width modulation) Raspberry Pi.
• I2C  GPID are the pins you use to ground your
• I2S devices. It doesn’t matter which pin you use as
• SPI they are all connected to the same line.

2. Serial VII. HOW TO NAVIGATE YOUR


These allow a massive range of sensors, motors, LEDs RASPEBERRY PI 3 MODEL B
and accessories to be connected to the Pi. Some of
the standard GPIO pins are used for communication
If you build it, they will program. The genesis of the
purposes. Here's a quick overview of these
Raspberry Pi came from a few college students
communication protocols!
concerned about the dwindling number and skills of
students applying to study Computer Science.
• SPI pins – The Serial Peripheral Interface (SPI) is
a communication protocol used to transfer data
Newer computers and game consoles have replaced
between micro-computers like the Raspberry Pi
the old machines where most of us learned to
and peripheral devices. The MISO pin receives
program. The creators capitalized on the powerful
data, and the MOSI pin sends data from the
and affordable processors designed for the booming
Raspberry Pi. Furthermore, the serial clock pin
mobile device arena, and they were able to create an
sends pulses at a regular frequency between the
economical, programmable computer with attractive
Raspberry Pi and the SPI device at the same

Page 5 of 11
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

graphics that could boot into the programming physical components: a new friendly Python API
environment and not break the bank. called GPIO Zero.

The Raspberry Pi is a credit card sized single-board The RPi. GPIO library is bare bones and provides all
computer with an open-source platform that has a the essential functionality to do simple things with
thriving community of its own, similar to that of the the Pi's GPIO pins—set up pins as inputs or outputs,
Arduino. It can be used in various types of projects read inputs, set outputs high or low, and so on. GPIO
from beginners learning how to code to hobbyists Zero is built on top of this and provides a collection
designing home automation systems. of simple interfaces to everyday components, so
rather than setting pin 2 high to turn on an LED, you
There are a few versions of the Raspberry Pi, but the have an LED object and you turn it on.
latest version, has improved upon its predecessor in
terms of both form and functionality. VIII. PROGRAMMING LED WITH GPIO
The Raspberry Pi Model B features:
GPIO are your standard pins that simply be used to
• More GPIO
turn devices on and off. For example, a LED.
• More USB
• Micro SD
• Lower power consumption
• Better audio
• Neater form factor

This higher-spec variant increases the Raspberry pi


GPIO pin count from 26 to 40 pins. There are now
four USB 2.0 ports compared to two on the Model B.
The SD card slot has been replaced with a more
modern push-push type micro SD slot. It consumes
slightly less power, provides better audio quality and
has a cleaner form factor.

To get started you need a Raspberry Pi 3 Model B, a Fig 8. LED (Light Emitting doide).
5V USB power supply of at least 2 amps with a
micro-USB cable, any standard USB keyboard and I2C (Inter-Integrated Circuit) pins allow you to
mouse, an HDMI cable and monitor/TV for display, connect and talk to hardware modules that support
and a micro SD card with the operating system pre- this protocol (I2C Protocol). This will typically take up
installed. The NOOBS (New Out Of the Box Software) 2 pins.
OS is recommended for beginners, and you may
choose one of several from the download page. SPI (Serial Peripheral Interface Bus) pins can be used
to connect and talk to SPI devices. Pretty much the
This pin out diagram will help you get familiar with same as I2C but makes use of a different protocol.
the layout of the board and get started in immersing
yourself into your own passion projects. UART (Universal asynchronous receiver/transmitter)
are the serial pins used to communicate with other
One of the most exciting starter activities to do with devices.
a Raspberry Pi is something you can't do on your • DNC stands for do not connect, this is self-
regular PC or laptop—make something happen in explanatory.
the real world, such as flash an LED or control a • The power pins pull power directly from the
motor. If you've done anything like this before, you Raspberry Pi.
probably did it with Python using the RPi.GPIO • GND are the pins you use to ground your
library, which has been used in countless projects. devices. It doesn’t matter which pin you use as
There's now an even simpler way to interact with they are all connected to the same line.
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

1. The Breadboard: 2. The Resistor:


The breadboard is a way of connecting electronic 330 Ohm Resistor. You must ALWAYS use resistors to
components to each other without having to solder connect LEDs up to the GPIO pins of the Raspberry
them together. They are often used to test a circuit Pi. The Raspberry Pi can only supply a small current
design before creating a Printed Circuit Board (PCB). (about 60mA). The LEDs will want to draw more, and
if allowed to them will burn out the Raspberry Pi.
The holes on the breadboard are connected in a Therefore, putting the resistors in the circuit will
pattern. ensure that only this small current will flow, and the
Raspberry Pi will not be damaged.

Resistors are a way of limiting the amount of


electricity going through a circuit; specifically, they
limit the amount of ‘current’ that is allowed to flow.
The measure of resistance is called the Ohm (Ω), and
the larger the resistance, the more it limits the
current. The value of a resistor is marked with
colored bands along the length of the resistor body.

You will be using a 330Ω resistor. You can identify


the 330Ω resistors by the colour bands along the
Fig 9. Breadboard. body. The colour coding will depend on how many
bands are on the resistors supplied:
With the breadboard in the CamJam EduKit, the top
row of holes are all connected together – marked • If there are four colour bands, they will be
with red dots? And so is the second row of holes – Orange, Orange, Brown, and then Gold.
marked with blue dots. The same goes for the two • If there are five bands, then the colours will be
rows of holes at the bottom of the breadboard. Orange, Orange, Black, Black, and Brown.
• It does not matter which way round you connect
In the middle, the columns of wires are connected the resistors. Current flows in both ways through
together with a break in the middle. So, for example, them.
all the green holes marked are connected, but they
are not connected to the yellow holes, or the purple 3. Jumper Wires:
ones. Therefore, any wire you poke into the green Jumper Wires are used on breadboards to ‘jump’
holes will be connected to other wires poked into the from one connection to another. The ones you will
other green LED. be using in this circuit have different connectors on
each end. The end with the ‘pin’ will go into the
A Red LED When you pick up the LED, you will notice Breadboard. The end with the piece of plastic with a
that one leg is longer than the other. The longer leg hole in it will go onto the Raspberry Pi’s GPIO pins.
(known as the ‘anode’) is always connected to the
positive supply of the circuit. The shorter leg (known 4. The Raspberry Pi's GPIO Pins
as the ‘cathode’) is connected to the negative side of GPIO stands for General Purpose Input Output. It is a
the power supply, known as ‘ground’. LED stands for way the Raspberry Pi can control and monitor the
Light Emitting Diode, and glows when electricity is outside world by being connected to electronic
passed through it. circuits. The Raspberry Pi can control LEDs, turning
them on or off, or motors, or many other things. It is
LEDs will only work if power is supplied the correct also able to detect whether a switch has been
way round ( i.e. if the ‘polarity’ is correct). You will pressed, or temperature, or light.
not break the LEDs if you connect them the wrong
way round – they will just not light. If you find that In the CamJam EduKit you will learn to control LEDs
they do not light in your circuit, it may be because and a buzzer, and detect when a button has been
they have been connected the wrong way round pressed. The diagram below left shows the pin layout
holes. for a Raspberry Pi Models A and B (Rev 2 - the
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

original Rev 1 Pi is slightly different), looking at the LEDs have many advantages over incandescent light
Raspberry Pi with the pins in the top right corner. sources, including lower power consumption, longer
The new 40 pin Raspberry Pi’s shares exactly the lifetime, improved physical robustness, smaller size,
same layout of pins for the top 13 rows of GPIO pins. and faster switching. In exchange for these generally
favorable attributes, disadvantages of LEDs include
IX. BUILDING THE CIRCUIT electrical limitations to low voltage and generally to
DC (not AC) power, inability to provide steady
illumination from a pulsing DC or an AC electrical
• The circuit consists of a power supply (the
supply source, and lesser maximum operating
Raspberry Pi), an LED that lights when the power
temperature and storage temperature.
is applied, and a resistor to limit the current that
can flow through the circuit.
In contrast to LEDs, incandescent lamps can be made
• You will be using one of the ‘ground’ (GND) pins
to intrinsically run at virtually any supply voltage, can
to act like the ‘negative’ or 0 volt ends of a
utilize either AC or DC current interchangeably, and
battery. The ‘positive’ end of the battery will be
will provide steady illumination when powered by AC
provided by a GPIO pin. Here we will be using
or pulsing DC even at a frequency as low as 50 Hz.
pin 18. When they are ‘taken high’, which means
LEDs usually need electronic support components to
it outputs 3.3 volts, the LED will light. Now take a
function, while an incandescent bulb can and usually
look at the circuit diagram below.
does operate directly from an unregulated DC or AC
power source.
1. A Single LED:
A light-emitting diode (LED) is a semiconductor light
LEDs are made in different packages for different
source that emits light when current flows through it.
applications. A single or a few LED junctions may be
Electrons in the semiconductor recombine with
packed in one miniature device for use as an
electron holes, releasing energy in the form of
indicator or pilot lamp. An LED array may include
photons. The color of the light (corresponding to the
controlling circuits within the same package, which
energy of the photons) is determined by the energy
may range from a simple resistor, blinking or color
required for electrons to cross the band gap of the
changing control, or an addressable controller for
semiconductor.[5] White light is obtained by using
RGB devices. Higher-powered white-emitting devices
multiple semiconductors or a layer of light-emitting
will be mounted on heat sinks and will be used for
phosphor on the semiconductor device.[6]
illumination. Alphanumeric displays in dot matrix or
bar formats are widely available. Special packages
Appearing as practical electronic components in
permit connection of LEDs to optical fibers for high-
1962, the earliest LEDs emitted low-intensity infrared
speed data communication links.
(IR) light.[7] Infrared LEDs are used in remote-control
circuits, such as those used with a wide variety of
The circuit consists of a power supply (the Raspberry
consumer electronics. The first visible-light LEDs were
Pi), an LED that lights when the power is applied, and
of low intensity and limited to red. Early LEDs were
a resistor to limit the current that can flow through
often used as indicator lamps, replacing small
the circuit.
incandescent bulbs, and in seven-segment displays.
• Efficiency: LEDs emit more lumens per watt than
incandescent light bulbs.[138] The efficiency of
Recent developments have produced LEDs available
LED lighting fixtures is not affected by shape and
in visible, ultraviolet (UV), and infrared wavelengths,
size, unlike fluorescent light bulbs or tubes.
with high, low, or intermediate light output, for
• Color: LEDs can emit light of an intended color
instance white LEDs suitable for room and outdoor
without using any color filters as traditional
area lighting. LEDs have also given rise to new types
lighting methods need. This is more efficient and
of displays and sensors, while their high switching
can lower initial costs.
rates are useful in advanced communications
• Size: LEDs can be very small (smaller than 2 mm2
technology with applications as diverse as aviation
[139]) and are easily attached to printed circuit
lighting, fairy lights, automotive headlamps,
boards.
advertising, general lighting, traffic signals, camera
• Warmup time: LEDs light up very quickly. A
flashes, lighted wallpaper, horticultural grow lights,
typical red indicator LED achieves full brightness
and medical devices.[8]

Page 8 of 11
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

in under a microsecond.[140] LEDs used in • You should turn your Raspberry Pi off for the
communications devices can have even faster next bit just in case you accidentally short
response times. something out.
• Cycling: LEDs are ideal for uses subject to • Use one of the jumper wires to connect a ground
frequent on-off cycling, unlike incandescent and pin to the rail, marked with blue, on the
fluorescent lamps that fail faster when cycled breadboard. The female end goes on the
often, or high-intensity discharge lamps (HID Raspberry Pi's pin, and the male end goes into a
lamps) that require a long time before restarting. hole on the breadboard.
• Dimming: LEDs can very easily be dimmed • Then connect the resistor from the same row on
either by pulse-width modulation or lowering the the breadboard to a column on the breadboard,
forward current. [141] this pulse-width as shown above.
modulation is why LED lights, particularly • Next, push the LEDs legs into the breadboard,
headlights on cars, when viewed on camera or by with the long leg (with the kink) on the right.
some people, seem to flash or flicker. This is a • Lastly, complete the circuit by connecting pin 18
type of stroboscopic effect. to the right-hand leg of the LED. This is shown
• Cool light: In contrast to most light sources, here with the orange wire.
LEDs radiate very little heat in the form of IR that
can cause damage to sensitive objects or fabrics. 2. The Code:
Wasted energy is dispersed as heat through the You are now ready to write some code to switch the
base of the LED. LED on. Turn on your Raspberry Pi and open the
• Slow failure: LEDs mainly fail by dimming over terminal window.
time, rather than the abrupt failure of
incandescent bulbs.[142] Create a new text file “LED.py” by typing the
• Lifetime: LEDs can have a relatively long useful following:
life. One report estimates 35,000 to 50,000 hours • nano LED.py
of useful life, though time to complete failure • Type in the following code:
may be shorter or longer.[143] Fluorescent tubes • import RPi.GP IO as GPIO
typically are rated at about 10,000 to 25,000 • import time
hours, depending partly on the conditions of use, • GPIO.setmode(GPIO.BCM)
and incandescent light bulbs at 1,000 to 2,000 • GPIO.setwarnings(False)
hours. Several DOE demonstrations have shown • GPIO.setup(18,GPIO.OUT)
that reduced maintenance costs from this • print "LED on"
extended lifetime, rather than energy savings, is • GPIO.output(18,GPIO.HIGH)
the primary factor in determining the payback • time.sleep(1)
period for an LED product.[144] • print "LED off"
• Shock resistance: LEDs, being solid-state • GPIO.output(18,GPIO.LOW)
components, are difficult to damage with
external shock, unlike fluorescent and Once you have typed all the code and checked it,
incandescent bulbs, which are fragile.[145] save and exit the text editor with “Ctrl + x” then “y”
• Focus: The solid package of the LED can be then “enter”.
designed to focus its light. Incandescent and
fluorescent sources often require an external 3. Running the Code:
reflector to collect light and direct it in a usable To run this code type:
manner. For larger LED packages total internal
reflection (TIR) lenses are often used to the same sudo python LED.py
effect. You will see the LED turn on for a second and then
turn off.
However, when large quantities of light are needed
many light sources are usually deployed, which are Explanation
difficult to focus or collimate towards the same So, what is happening in the code? Let’s go through
target. it a line at a time:

Page 9 of 11
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

import RPi. GPIO as GPIO: A longer life, brighter illumination and less electricity
The first line tells the Python interpreter (the thing consumption are some of the reasons why LED is
that runs the Python code) that it will be using a being chosen above others.
‘library’ that will tell it how to work with the
Raspberry Pi’s GPIO pins. A ‘library’ gives a
programming language extra commands that can be
used to do something different that it previously did
not know how to do. This is like adding a new
channel to your TV so you can watch something
different.

import time:
Imports the Time library so that we can pause the
script later on.

GPIO.setmode(GPIO.BCM)
Each pin on the Raspberry Pi has several different
names, so you need to tell the program which
naming convention is to be used.
Fig 10. LED Demonstration.
print "LED on"
Entertainment and furnishing markets are also trying
This line prints some information to the terminal.
to make the most out of the latest LED innovations
as well. Use of LED technology is on a rise in these
GPIO.output(18, GPIO.HIGH)
sectors and many LED manufacturing companies
This turns the GPIO pin ‘on’. What this means is that
have started designing and manufacturing their
the pin is made to provide power of 3.3volts. This is
products exclusively for entertainment and
enough to turn the LED in our circuit on.
decorative sectors.
time. sleep (1)
Superbright blue, green, and white InGaN SQW LEDs
Pauses the Python program for 1 second
have been discussed in this book. By combining
high-power, high-brightness blue InGaN SQW LEDs,
print "LED off"
green InGaN SQW LEDs, and red GaAlAs LEDs, many
This line prints some information to the terminal.
kinds of applications, such as LED full-color displays
and LED white lamps for use in place of light bulbs or
GPIO.output(18, GPIO.LOW)
fluorescent lamps, are now possible with
This turns the GPIO pin ‘off’, meaning that the pin is
characteristics of high reliability, high durability, and
no longer supplying any power.
low energy consumption. Also, a white LED made by
combining a blue InGaN SQW LED and YAG
And that's it! You are now able to turn an LED on and
phosphor, which was less expensive than a white LED
off.
composed of three primary color LEDs, has been
developed. The luminous efficiencies of the blue,
X. CONCLUSIONS green, and white LEDs are 3, 10, and 5 lm/W, which
are much higher than that of conventional light
LED light is blinked when we programmed it the help bulbs (1 lm/W).
of whiteboard if we are not having female to female
jumper wires. if we are having female to male jumper Superbright blue, green, and white InGaN SQW LEDs
wire, then whiteboard is required. We have used have been discussed in this book. By combining
resistors, led, with the help of python programming. high-power, high-brightness blue InGaN SQW LEDs,
green InGaN SQW LEDs, and red GaAlAs LEDs, many
LED innovations across various sectors including kinds of applications, such as LED full-color displays
hospitality, retail and entertainment among others. and LED white lamps for use in place of light bulbs or
Priyanka Dubey. International Journal of Science, Engineering and Technology, 2022, 10:3 International Journal of Science,
Engineering and Technology
An Open Access Journal

fluorescent lamps, are now possible with technologyintro-specifications-seminar-abstract-


characteristics of high reliability, high durability, and technical-report.html
low energy consumption. Also, a white LED made by [8] Working of RC4 Algorithm [Online]. Available:
combining a blue InGaN SQW LED and YAG http://securityblog.redhat.com/category/
phosphor, which was less expensive than a white LED [9] Cryptography/page/3/ [8] Rick Wash “Stream
composed of three primary color LEDs, has been Ciphers and RC4”, lecture notes of Computer
developed. Science, Working paper. September 2001.
[10] Nakul Padhye , Preet Jain Implementation of Arm
The luminous efficiencies of the blue, green, and Embedded Web Server for DAS using Raspberry
white LEDs are 3, 10, and 5 lm/W, which are much Pi, Vol.3 No.4 April 2013
higher than that of conventional light bulbs (1 [11] Jiang. J.N, Peng D.G, Zhang.H, (2008) Design and
lm/W) Realization of Embedded Web Server Based On
ARM and Linux. Mechatronics, Vol.14 (10):37-40
XI. FUTURE ENHANCEMENT [12] C. K. Lennard et al., "Industrially Proving the
SPIRIT Consortium Specifications for Design
Chain Integration", Proceedings of DATE 2006,
In future, the focus would be to develop own LED
pp. 1-6, March 2006.
with Raspberry Pi Embedded Systems project using
[13] K. Cho et al., "Reusable Platform Design
Raspberry Pi B/B+/Zero model.
Methodology For SOC Integration And
Verification", Proceedings of ISOCC 2008, pp. 1-
REFERENCES 78, -1-81, Nov. 2008.
[14] M. Strik et al., "Subsystem Exchange in a
[1] [1] Raspberry pi guide [Online]. Available:
Concurrent Design Process Environment",
http://www.raspberrypi.org/quick-start-guide [5]
Proceedings of DATE 2008, pp. 953-958, March
History And Hardware [Online]. Available:
2008.
http://en.wikipedia.org/wiki/Raspberry_Pi [6]
[15] Bhavnil Patel and Bhargav Tarpara, "Design and
William Stallings: Cryptography and Network
Implementation of General Purpose Input
Security, 4th Edition Prentice Hall
Output (GPIO) Protocol", International Journal of
[2] Ms. Sejal V. Gawande, Dr. Prashant R. Deshmuk “
Scientific Engineering and Applied Science
Raspberry Pi Technology” International Journal
(IJSEAS), vol. 1, no. 3, June 2015.
of Advanced Research in Computer Science and
Software Engineering Volume 5, Issue 4,April
2015ISSN: 2277 128X
[3] Cheah Wai Zhao et al. “ Exploring IOT
Application Using Raspberry Pi” International
Journal of Computer Networks and Applications
Volume 2, Issue 1, January –February (2015)
th
[4] The 16 Winona Computer Science, Under
graduate Research Symposium, April 27, 2016,
Kryzsko Commons Purple Rooms 247 & 248,
Winona State University Winona, MN
[5] Patel urjja and Neha chitaliya “IP based device
control and monitoring system using raspberry
pi based on IOT” (IJIET) Volume 7 Issue 1 June
2016.
[6] Raspberry pi. [Online]. Available: http://www
.raspberrypi.org/ [2] Eben Upton, Gareth
Halfacree: Raspberry Pi® User Guide 1st edition
2010 John Wiley & Sons Ltd., Publication, United
Kingdom.
[7] Raspberry Pi Technology [Online]. Available:
http://www.collegelib.com/t-raspberry-pi-

Page 11 of 11

You might also like