In the following example we will connect an LED and resistor to pin 7 of P1 on our Raspberry PI and we will flash an LED on, here is a picture of this
OK we will use python, this tutorial assumes you already have Raspbian , Python and the GPIO library installed. I downloaded the latest NOOBS image and this all appeared to be installed by default
Open the terminal and type in the following
sudo idle
You should see something like this
Wait for IDLE to open, then click File > New to open a new window. Or you can use CTRL + N, you can see this below.
Now type in the following code
import RPi.GPIO as GPIO ## Import GPIO library
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
GPIO.setup(7, GPIO.OUT) ## Setup GPIO Pin 7 to OUT
GPIO.output(7,True) ## Turn on GPIO pin 7
Click File > Save when you are finished (Ctrl + S).
To run your program, click Run > Run (Ctrl + F5), your LED should light