LED Blinking With Raspberry Pi

291,021

106

10

One of the classic electronic analogy to "Hello World" is to make an LED blink. Raspberry Pi has 8 General Purpose Input/Output pins( 4,17,18,21,22,23,24,25) which can be configured as input/output and turned on/off via software.In this Instructable I will be using python to control the LED, as coding in python is very simple yet it's very powerful. RPi.GPIO Python library is used to control the LED from Raspberry Pi.

Step 1: Hardware Setup

Place the LED with a 270 ohm resistor in series with the GND and GPIO pin of Raspberry Pi (use a breadboard for hassle free connection). Always use a resistor with LEDs to limit the current, else you might end up with a burnt LED ;)

For complete details & schematics, please visit my blog :- http://www.rpiblog.com/2012/09/using-gpio-of-raspberry-pi-to-blink-led.html

Step 2: Code

Python is used to control the GPIO's in Raspberry Pi.

For complete details & code, please visit my blog :- https://www.raspinews.com/blinking-led-on-raspberry-pi-using-python

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Big and Small Contest

      Big and Small Contest
    • Toys Contest

      Toys Contest

    10 Discussions

    0
    None
    tlangelanim

    2 years ago

    i have raspberry pi 3, I have installed python 3 but when I wright a code on python it says import RPi.GPIO as GPIO, ImportError: No module named 'RPi' please help

    2 replies
    0
    None
    BisratMtlangelanim

    Reply 1 year ago

    GPIO is a general in put out library that allow you to use the pin on the raspberry , but it has nothing to do with writing a code. you can easily write a code by using 'sudo nano test.py' . use GPIO if you want output or input from the raspberry . i hope it helps . good luck

    0
    None
    IranRtlangelanim

    Reply 2 years ago

    Did you have the RPi.GPIO library installed? If not, you have to install.

    If you're using raspbian this may work for you:

    $ sudo apt-get install python-rpi.gpio python3-rpi.gpio

    (sorry about the poor english :) )

    0
    None
    StefanH4

    4 years ago on Introduction

    Thanks. I made it thanks to your blog, which made it easy enough to try out. Now I hope I can get some tutorial on how to make it blink with C (will look thru your blog) and later make some bitbanging which should emuilate PS/2 keyboard output. If anyone has done this, or emulated a keyboard successfully in some other wired way (non-bluetooth), please let me know. Thanks.

    1 reply
    0
    None
    MichaelM113StefanH4

    Reply 1 year ago

    Sounds like you want to configure your Pi in USB gadget mode, using the HID module. That would make your Pi appear to be a USB keyboard.

    https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/other-modules

    0
    None
    neontime

    4 years ago on Introduction

    The forward voltage of a red LED will be around 1.5V minimum, other colours will be higher. So its 3.3 - 1.5 across 270 ohms. The current will be 6mA or less depending on the LED so it's quite safe.

    0
    None
    ed.cole.980

    4 years ago on Introduction

    Do the math please. 3.3V less 0.6 over the LED thru 270ohm is 10mA, which is twice what the GPIO pin can source or sink. Yeah, it will blink for a while, but stress it with this current and it will fry the pin if not the chip. There can be nothing more disappointing than being encouraged to fry your board by someone with such a poor understanding of electronics.

    1 reply