0% found this document useful (0 votes)
245 views3 pages

05 - LED Blinking

The document describes an experiment to interface an LED with a Raspberry Pi and write a Python program to blink the LED. The program turns the LED on for 1 second and then off for 1 second, repeating continuously. The circuit connects the LED and resistor to GPIO pins on the Raspberry Pi. The Python code imports libraries, sets the GPIO mode and pin, and uses a while loop with sleep functions to toggle the pin and blink the LED.

Uploaded by

Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
245 views3 pages

05 - LED Blinking

The document describes an experiment to interface an LED with a Raspberry Pi and write a Python program to blink the LED. The program turns the LED on for 1 second and then off for 1 second, repeating continuously. The circuit connects the LED and resistor to GPIO pins on the Raspberry Pi. The Python code imports libraries, sets the GPIO mode and pin, and uses a while loop with sleep functions to toggle the pin and blink the LED.

Uploaded by

Shivani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT NO 05

TITLE: To interface LED with Rasberry Pi and write a program to turn on LED

AIM: To interface LED with Raspberry Pi and write a program to turn ON LED for 1 sec after every 2
seconds.

SCOPE:
Understanding of LED interfacing with Raspberry Pi and execution of a program to turn ON LED
for 1 sec after every 2 seconds

FACILITIES/ APPARATUS:
i) Hardware:
Raspberry Pi 3 (B+) with Monitor, USB Keyboard, USB Mouse, HDMI-VGA Convertor, A high-
quality 2.5A micro USB power supply and Micro SD card with NOOBS, 5mm LED, 1KΩ Resistor
(1/4 Watt),Mini Breadboard and Connecting wires.
ii) Software:
Raspbian Operating System, Python 3.0

THEORY:
LED blinking is one of the beginner circuits which help one to get acquainted with GPIO pins of Raspberry
Pi. Here we use Python language to write the code for blinking Led at one second intervals.
Raspberry Pi is a pocket sized computer which also has GPIO pins for connecting it to other sensors
and peripherals which makes it a good platform for embedded engineers. It has an ARM architecture
processor based board designed for electronic engineers and hobbyists. The PI is one of most trusted
project development platforms out there now. With higher processor speed and high RAM, the Raspberry
Pi can be used for many high profile projects like Image processing and Internet of Things. Raspberry Pi
4 with 8GB RAM is the high end version available for sale now. It also has another lower version with 4GB
and 2GB RAM.
CIRCUIT ARRANGEMENT:
The first step in this project is to design a simple LED circuit, and then we can make the LED circuit
controllable from the Raspberry Pi by connecting the circuit to the general purpose input/output (GPIO)
pins on the Raspberry Pi.
A simple LED circuit consists of a LED and resistor. The resistor is used to limit the current that is being
drawn and is called a current limiting resistor. Without the resistor the LED would run at too high of a
voltage, resulting in too much current being drawn which in turn would instantly burn the LED, and likely
also the GPIO port on the Raspberry Pi.
When hooking up the circuit note the polarity of the LED. You will notice that the LED has a long and
short lead. The long lead is the positive side also called the anode, the short lead is the negative side
called the cathode. The long should be connected to the resistor and the short lead should be connected
to ground via the blue jumper wire and pin 6(ground) on the Raspberry Pi as shown on the
diagram.Connect other end of register to Pin 8 of Raspberry Pi kit using jumper wire. To find the pin
number refer to this diagram showing the physical pin numbers on the Raspberry Pi.
If the program has no errors in it, you will see a “>>>”,
which means the program is executed successfully. By this time you should see the LED blinking three
times. If there were any errors in the program, the execution is corrected. Once the error is corrected,
execute the program again.

CODE:
$ sudo apt-get install python-rpi.gpio python3-rpi.gpio
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import sleep function from time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) # Set pin-8 as o/p pin and set it to low
while True: # Run forever
GPIO.output(8, GPIO.HIGH) # Turn on
sleep(1) # Sleep for 1 second
GPIO.output(8, GPIO.LOW) # Turn off
sleep(1) # Sleep for 1 second
$ python blinking_led.py
CONCLUSION:
The LED has interfaced with Raspberry Pi and a program has executed to turn ON LED for 1 sec after
every 2 seconds.
OUTPUT:
The LED connected to the Raspberry Pi repeatedly blinks after the interval of one second
Circuit diagram for Raspberry Pi LED Blink:

You might also like