Raspberry Pi 5 LED Blink

This tutorial explains how to blink LED using Raspberry Pi 5.

Python Code for Hello World:

print ("Hello, World!")

Python Code for LED Blink using GPIO.BOARD Command:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(3,GPIO.OUT)

while True:
    GPIO.output(3, True)
    time.sleep(1)
    GPIO.output(3,False)
    time.sleep(1)

Python Code for LED Blink using GPIO.BCM Command:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(2,GPIO.OUT)

while True:
    print("LED on")
    #GPIO.output(2, GPIO.HIGH)
    GPIO.output(2, True)
    time.sleep(1)
    print("LED off")
    #GPIO.output(2, GPIO.LOW)
    GPIO.output(2,False)
    time.sleep(1)

Here is the link of our video tutorial for Raspberry Pi 5 LED Blink:

Comments/Feedback:

Leave a comment