

In this tutorial you will learn how to interface a LED with Raspberry Pi. Just follow the Instructions below. In order to setup VNC and control Raspberry Pi from your PC use this tutorial http://www.learn2crack.com/2013/08/setup-vnc-server-in-raspberry-pi-linux.html and to set up SD card for your Raspberry Pi use this tutorial http://www.learn2crack.com/2013/08/setup-sd-card-for-raspberry-pi.html.
Requirements:
1.Breadboards
2.LEDs
3.Jumper wires
Instructions to Glow LED:
1.Just take a look at the GPIO diagram of Raspberry Pi, which will give you a understanding of GPIO structure.
2.Connect GPIO 25 of Raspberry Pi to to the Anode of the LED through connecting jumper wires and Breadboard.
3.Connect Ground of Raspberry Pi to Cathode of the LED through connecting wires and breadboard.
4.Now power up your Raspberry Pi and boot.
5.Open the terminal and enter the commands to glow an LED.
Enter sudo su to drop you into the root terminal
root@raspberrypi:/home/pi# echo 25 > /sys/class/gpio/export root@raspberrypi:/home/pi# cd /sys/class/gpio/gpio25 root@raspberrypi:/sys/class/gpio/gpio25# echo out > direction root@raspberrypi:/sys/class/gpio/gpio25# echo 1 > value
6.To turn of an LED enter the command in terminal
root@raspberrypi:/sys/class/gpio/gpio25# echo 0 > value
You can also combine these commands into shell script and execute.
Instructions to Blink LED:
1.Open terminal and type nano blinkled.py
2.It will open the nano editor. Paste the python LED blink code
and save
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(25, GPIO.OUT) while True: GPIO.output(25, GPIO.HIGH) time.sleep(1) GPIO.output(25, GPIO.LOW) time.sleep(1)
3. Now run the code python blinkled.py
4.Now LED will be blinking at a interval of 1s. You can also change the interval by modifying time.sleep in the file.
5.Press Ctrl+C to stop LED from blinking.
Enjoy:)
Any questions comment here.
[Also Read : Setup SD Card for Raspberry Pi in Windows and Linux]