Introduction
What you will need
- Raspberry Pi configure with GPIO library
- 1-Small led
- 1-50 ohm Resistor
- Some solid-core wires
- Bread Board
Let there be light
Before we get around to write the code, let's first get acquainted with the pin numbering of our RPI and create a simple circuit.
- Pin 1 (+3.3v) should go to longer led to the led Pin.
- Attach the shorter led pin to the resistor and finally attach the other end of the resistor to pin-6(GND) on your RPI.
Figure1 - Connection
Controlling the led with our python code
I like to write Python code in IDLE IDE because it comes packaged with Raspbian distribution as it's free and allows us to write to our cod a little bit easier than Python command line or a text editor.
- Power on your RPI and boot all the way in the operating system GUI.
- Open the terminal and launch the IDLE IDE.
- Click File > New to open a new window.
Code
- import RPi.GPIO as GPIO
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(1, GPIO.OUT)
- GPIO.output(1,True)
- Import GPIO library
- Use board pin numbering
- Setup GPIO Pin 1 to OUT
- Turn on GPIO pin 1

Delpin Susai RajPosted Aug 28, 2016, 4:18 AM
Nice
Santhakumar MunuswamyPosted Jun 9, 2016, 12:30 AM
Thank you for nice share
Sr KarthigaPosted Jun 8, 2016, 10:09 PM
"nice share sir"
Vignesh ManiPosted Jun 7, 2016, 6:59 AM
Nice
Prasanna MuraliPosted Jun 7, 2016, 3:31 AM
Nice one...
Kumaresh RajalingamPosted Jun 7, 2016, 3:02 AM
Thanks Saha
Debasis SahaPosted Jun 7, 2016, 12:55 AM
Nice share..
Kumaresh RajalingamPosted Jun 6, 2016, 9:38 PM
Thanks Sonu Chaudhary
Sonu ChaudharyPosted Jun 6, 2016, 1:50 PM
good one