Raspberry Pi Tutorial of LED Blinking

by Tatsu Technologies in Circuits > Raspberry Pi

1107 Views, 3 Favorites, 0 Comments

Raspberry Pi Tutorial of LED Blinking

Raspberry Pi 3 | Tutorial - 1 | LED blinking

Requirement:

  • Raspberry Pi
  • BreadBoard or T-Cobbler
  • Jumper Wires
  • LED

Click here for More Information

Connect Your Raspberry Pi GPIO With LED on Breadboard or Multi-function Board

GPIO-led-diagram.png

Now as per video you can use pin number 27 as output and connect GND with led's GND terminal,

Make sure your GPIO connection should be correct.

Setup

Blinking-LED-Raspberry-Pi-Wiring-768x597-1.png

Connect LED on breadbard or T-cobbler as attached video.

Install GPIO Libraries

$ sudo apt-get update

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

Program

import RPi.GPIO as GPIO

import time

LedPin = 11 # pin11

def setup():

GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location

GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output

GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to turn on led

def blink():

while True:

GPIO.output(LedPin, GPIO.HIGH) # led on

sleep(1)

GPIO.output(LedPin, GPIO.LOW) # led off time.sleep(1)

def destroy():

GPIO.output(LedPin, GPIO.LOW) # led off

GPIO.cleanup() # Release resource

if __name__ == '__main__':

setup()

try:

blink()

except KeyboardInterrupt:

destroy()