0% found this document useful (0 votes)
53 views1 page

Gpio and The Raspberry Pi: 3. 1.: Can't

This document provides instructions for using a Raspberry Pi with Python code to light up an LED. It explains that GPIO stands for General Purpose Input Output and is used to control components connected to the Pi. It lists the required parts, including an LED, resistor, breadboard and Pi. It provides code to import the GPIO library, set the mode and pin, and output true or false to turn the LED on and off. Connections are made from pins on the Pi through the breadboard to the resistor and LED. Running the code in super user mode will light up the LED. Potential issues are also outlined.

Uploaded by

Kalpit Sahoo
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)
53 views1 page

Gpio and The Raspberry Pi: 3. 1.: Can't

This document provides instructions for using a Raspberry Pi with Python code to light up an LED. It explains that GPIO stands for General Purpose Input Output and is used to control components connected to the Pi. It lists the required parts, including an LED, resistor, breadboard and Pi. It provides code to import the GPIO library, set the mode and pin, and output true or false to turn the LED on and off. Connections are made from pins on the Pi through the breadboard to the resistor and LED. Running the code in super user mode will light up the LED. Potential issues are also outlined.

Uploaded by

Kalpit Sahoo
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/ 1

GPIO AND THE RASPBERRY Pi: A Beginners Guide to Using Python, GPIO & the Raspberry Pi to Code And

Light up an Led

1. GETTING STARTED 2. WARNING 3. PARTS / COMPONENTS


1

So you want to make an LED light up, You cant just connect an LED and You require the following parts, leads (male to female ends), LEDs, Resistors suitable for
using your Raspberry Pi and Python? light it up it may blow up the light or the LED, Solder-less Breadboard, (The clever little breadboard allows you to create a circuit
even blow up your Pi. All normal without having to solder any components. It is important to make sure you know which way
First things first, GPIO stands for the connections run, usually horizontally), and your Raspberry Pi. It is also worth getting the
electrical safety procedures should be
General Purpose Input Output, LED most up to date Disk Image for you Pi from the official site.
followed. If unsure, dont do it!
stands for Light Emitting Diode. A diode
allows a current to flow, usually in one To calculate what resistor to use with which LED use this tool,
direction. Current is a flow of electrons http://www.hebeiltd.com.cn/?p=zz.led.resistor.calculator
or more commonly known as electricity!
To calculate the resistance value use this useful online tool:
6. PROGRAMMING CODE http://www.csgnetwork.com/resistcolcalc.html
Using Python 2.6 create the program below.
Or, most electronics shops will calculate the LED and resistance to use before you buy.
Import RPi.GPIO as GPIO
GPIO setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT) 4. CONNECTING THE WIRES
GPIO.output(11.True) The first part is to connect the wires, the first from PIN11, this is the output wire which you
will program to provide a current to the LED. The second wire, PIN6 is for the current to
-GPIO.setup(11, GPIO.OUT) tells the Pi which PIN the current is following out of, return back to the Pi and complete the circuit. (This PIN is rated 0V). If you imagine that
-GPIO.output(11.True) tells the Pi that the output is true, therefore the LED is on PINs11 and 6 are taps and are joined together with a pipe. If you turned the PIN 11 tap on
-To turn the LED off use False, GPIO.output(11.False) the water would flow from PIN11 through the pipe to 6. This happens with the current, it
-Use the import Time, and time.sleep(4) between the True and False, flows from PIN 11 through the LED to PIN 6.
(On and Off) to make the LED turn on for 4 seconds then turn off.

You may be required to install the GPIO module. Open the LX Terminal and type 5. CONNECT THE LED
PIN 6
AND THE RESISTOR.
the code, sudo apt-get install python-rpi.gpio
The long leg of the LED is
the positive end which PIN 11
7. RUN THE CODE COMMON ISSUES must be connected to the
Broken LED, wires PIN 11 wire, the current. If
The program will only run in the Super User mode open in wrong PIN,
the LX Terminal and run using the SUDO command.
you get this around the
coding error,
Sudo python the nameofyourprogram.py components not
wrong way you can blow
pushed into the LED. PIN 6 feeds the
breadboard, current back to the Pi.
Resistor too high, PIN6 should be in line with
broken wire the LED short leg. @Dan_Aldred

EXTRA IDEAS: Connect two LEDs: Create a Quiz, if correct answer green LED lights up, if not Red LED lights: Set up a traffic light simulator: If you receive a Tweet the LED lights up

You might also like