Blinking a LED With Raspberry Pi
by prayag nao in Circuits > Raspberry Pi
4686 Views, 16 Favorites, 0 Comments
Blinking a LED With Raspberry Pi
![example1.jpg](/proxy/?url=https://content.instructables.com/FUT/0SN8/IH8782H4/FUT0SN8IH8782H4.jpg&filename=example1.jpg)
Today i am going to post how to blink a led with raspberry pi. Blinking a LED is a beginner task and simple task.
components required:
- Raspberry pi.
- 2 Male to female connectors.
- A 330 omh resistance.
- A LED.
- A breadboard.
Procedure
![j8header-2b-large.png](/proxy/?url=https://content.instructables.com/F24/OKSR/IH8782B1/F24OKSRIH8782B1.png&filename=j8header-2b-large.png)
Here is pin diagram of Raspberry pi 2.
- Connect 11th pin to one end of resistance.
- Connect ground pin to -ev pin of LED.
- Now connect remaining end of resistance to +ev of LED.
- Now turn on Raspberry pi.
- open text editor and paste following program into it.
Programming
![shutterstock_computer_programming.jpg](/proxy/?url=https://content.instructables.com/F4M/1A76/IH8782U2/F4M1A76IH8782U2.jpg&filename=shutterstock_computer_programming.jpg)
import GPIO.RPi as GPIO ##import GPIO library
import time
GPIO.setmode(GPIO.BOARD) ##use board pin numbering
GPIO.setup(11,GPIO.OUT) ##set 11th pin as output pin
while 1:
GPIO.output(11,1) ## Turn on led
time.sleep(1) ## 1 second delay
GPIO.output(11,0) ## Turn off led
time.sleep(1)
Finalize
- Save above program as blink.py.
- Now run above program as root user and you will see blinking led.