loading
Overview of Steps

In the first phase, I will install only one LED. Next, I download the LED class python module that represent one hardware LED. I will run the LED class python module to blink that LED. The first phase serves as a "Proof of Concept".

In the second phase, I will install another 4 LEDs. Finally, I run the python main module to create a series of five sequentially blinking LEDs as depicted in the video above

Step 1: Materials

Gather the following materials:

1 Raspberry Pi device running on standard Raspbian Linux installation
5 LEDs rated at 2.4V

5 Resistor (can be between 185 Ohms to 270 Ohms)

1 breadboard

6 Female to Male Jumper Wire

5 single-core wire (also called solid wires, solid-core or single-strand wire, consists of one piece of metal wire. Solid wire is useful for wiring breadboards. I stripped an unused telephone wire to get the single-core wire. There are 4 thin insulated single-core wire in a telephone cable. Choose any one and strip the insulator off just enough to expose bare metal at the two ends.)

Step 2: Installing the First LED

WARNING

Be careful when installing the LED with the Raspberry Pi as it may short-circuit and damage Raspberry Pi device. Do this at your own risk. Remove all power supply source from your Raspberry Pi device.

Materials

The following materials are required:

1 X Raspberry Pi
1 x LED

1 X 165 Ohm Resistor

2 X Male-Female Jumper Wire

1 X 5cm single core wire 1 X Breadboard

Installation
  1. Read to the GPIO diagram to locate the pins.
  2. Connect female end of jumper wire to the GPIO Pin 11. (This pin will be programmed to supply 3.3 Volts)
  3. Connect male end of jumber wire to the breadboard as shown in video.
  4. Connect resistor to breadboard as show in video.
  5. Connect LED to breadboard as shown in video.
  6. Connect the single-core wire as shown in video
  7. Connect female end of another jumper wire to GPIO Pin 6 (This pis is at 0 Volts.)

Step 3: Start Up Raspberry Pi

  1. Boot up the Raspberry Pi by pluggin in the power supply micro usb
  2. Log in using pi account

Step 4: Use a Python Class Module to Flash an LED

  1. Load the LXTerminal.
  2. Install or update the Rpi.GPIO software by typing the following bold commands. The command might ask you for your input:

    pi@raspberrypi ~ $ sudo apt-get update

    pi@raspberrypi ~ $ sudo apt-get install python-rpi.gpio

  3. Download the attached file called led.py and saved it as led.py in Raspberry Pi directory: /home/pi/python_proj/gpio
  4. Load the IDLE by typing the following:

    pi@raspberrypi ~ $ sudo idle

  5. On the IDLE's Python Shell Window: Click File -> Open -> Choose led.py that you saved in #1 of this step
  6. Read the documentation and source codes of led.py.
  7. In IDLE's Python Shell Window, type the following

    >>>import sys

  8. Then press ENTER
  9. Type the following:

    >>>sys.path.append('/home/pi/python_proj/gpio')

  10. Then press ENTER
  11. Type the following:

    >>>import led

  12. Then press ENTER
  13. Type the following to setup the LED connected to Pin 11:

    >>>led11 = led.Led(11)

  14. Then press ENTER
  15. Type the following to blink the LED connected to Pin 11:

    >>>led11.blink_non_stop()

  16. Then press ENTER key
  17. Observe that the LED blinks continuously.
  18. Press Ctlr+C to exit program

  19. Type the following:

    >>>led11.clean_up()

  20. You have successfully completed the "Proof of Concept" phase if the LED blinks continuously.

Step 5: Install and Test the Next 4 LEDs

Materials

You need the following:

4 x LED

4 X 165 Ohm Resistor

4 X Male-Female Jumper Wire

4 X 5cm single core wire

Installation
  1. Shut down Rasbian OS
  2. Unplug the power cable off Raspberry Pi
  3. Follow the same instruction described in Step 2.
  4. Use the following GPIO Pin:
    Pin 12
    Pin 15
    Pin 16
    Pin 18

  5. Play the attached video for detail to see the layout of the components in the breadboard and Raspberry Pi
  6. Load the IDLE (Python Editor) by typing the following:

    pi@raspberrypi ~ $ sudo idle
  7. On the IDLE's Python Shell Window: Click File -> Open -> Choose led.py
  8. In IDLE's Python Shell Window, type the following:

    >>>import sys
  9. Then press ENTER
  10. Type the following:

    >>>sys.path.append('/home/pi/python_proj/gpio')
  11. Then press ENTER
  12. Type the following:

    >>>import led
  13. Then press ENTER
  14. Type the following:

    >>>led12 = led.Led(12)
  15. Then press ENTER
  16. Type the following:

    >>>led12.blink_non_stop()
  17. Then press ENTER key
  18. Observe the LED blinks continuously.
  19. Press Ctlr+C to exit program
  20. Type the following:

    >>>led12.clean_up()
  21. Repeat instructions No 11-15 for the rest of the LEDs. Remember to change the Pin number for each LED:

    led15 = led.Led(15)

    led16 = led.Led(16)

    led18 = led.Led(18)

Step 6: Blink the Series of LEDs

  1. Download led_effects.py and led_main.py and save the 2 files as its original name in /home/pi/python_proj/gpio
  2. In IDLE's Python Shell window, click Menu -> Open -> Choose led_effects.py
  3. Read the source codes
  4. In IDLE's Python Shell window, click Menu -> Open -> Choose led_main.py

  5. Read the source codes

  6. In the window that displays led_main.py, click on Run -> Run Module
  7. Observe all 5 LEDs blinking in sequential order
<p>is it all right if u can post the code too, that would be awesome!</p>

About This Instructable

7,388views

14favorites

License:

Bio: Systems Administrator and Software Programmer.
More by mirza irwan osman:Install Modem USB Device in Raspberry Pi Make the Volume Knob of Sound Blaster X-Fi Surround 5.1 Pro Sound Card Work in Raspberry Pi Create a Volume Control for USB Sound Card in Raspberry Pi 
Add instructable to: