LED Blinking

3204 0

You will need the following things:

  1. Raspberry pi configured (see previos lessons)
  2. 5 Volt LED bulb(s)
  3. 2 jumper wires m/f
  4. 1 wire cutter with wire striper. (often found on long pliers)

 

First you will need to  open terminal.What you need to type in terminal is :

 

Then you need to install the python development code:

 

Then you type:

 

Now we are done preparing your raspberry pi now lets prepare your cables and LED’s.

IMG_5049

 😎 First you should cut the Cable

On the same side of the wire strip off about one quarter inch with your wire cutter. You do this by placing the wire into the knot on the bottom. apply a little bit of pressure and pull down and back. After that you should have a striped wire. Do this twice.

With your striped wire you will want to find the LED and attach each of the striped sides of the wire to the LED leads.

IMG_5045

Please notice that on of the pins on your LEDs are not the same length. The long LED pin is the positive side and the short LED pin is the negative side. Remember which color wire you attached to the positive side and which on you connected to the negative.

IMG_3001

We need to connect the negative pin to any ground pin on your GPIO like in the pictures below. To find the pins on your raspberry pi i also included a pin chart to the raspberry pi 2 middle B, you might need to use Google if you have an older model of the raspberry pi.

Notice i used pin number 9 for my ground pin.

 

To do this you must connect the other wire to a positive pin out i used pin GPIO 11 after this it is time to write the program!!!!!!!!!!!!!!!!!!!!!!! 😎 😎

 

Go into the raspberry pi Menu, and under accessories, choose text editor. In your new file type your shebang line, same as before #!/usr/bin/python at the top. Skip a line and add the following code:

 

This sets the words GPIO and time to the commands wee will use for blinking ouor light and pausing. Next you will need the following commands.

This tells python to let us use the  GPIO pin board we then tell it to use the GPIO pin No. 11, to set it up for output, and to send 5v out through the pin. This makes your LED light up.

Now let’s finish our code:

This is the last of your code, you should now save your file. You should save it to Desktop at least thats what i did. I made my file “test_blink.py”, but you can name yours what ever you want.

Above, “time.sleep(.2)” tells our code to pause for 2.1 seconds, then “GPIO.output(11,GPIO.LOW)” turns the LED off again. “GPIO.cleanup()” tells the pi to clean every thing up, and let other programs use GPIO.

Now it time to make our code executable and run it, just like last lesson. Type the following command into your terminal:

Now your LED will blink.

 

IMG_2996

Facebooktwitterredditpinterestlinkedinmail

Related Post

Add Clock Via i2c

Posted by - October 24, 2015 0
Prepare i2c added real time clock driver to raspian Add time variable to picture display Solder pins to clock module…

Make Them Blink

Posted by - November 15, 2015 0
You will need: 4 complete sets of LED’s and wires (see last lesson) The first thing you will need to…

Identify USB device and discover its name and port

Posted by - October 17, 2015 0
Download latest PyUSB from : http://sourceforge.net/projects/pyusb/files/PyUSB%201.0/1.0.0-beta-2/pyusb-1.0.0b2.tar.gz/download Place file “pyusb-1.0.0b2.tar.gz” on your desktop gunzip <pyusb-1.0.0b2.tar.gz |tar xvfp - cd pyusb-1.0.0b2 sudo ./setup.py…

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.