In this video, I demonstrate how to control an LED using Raspberry Pi 5 and Python with the gpiozero library. The program turns the LED on and off before making it blink 5 times with a 2-second ON time and a 1-second OFF time.
🔹 Hardware Used: Raspberry Pi 5, LED, Resistor, Jumper Wires
🔹 Software: Python, GPIO Zero Library
🔹 Code Explanation: The script uses LED.on(), LED.off(), and LED.blink() functions to control the LED's behavior.
Code:
from gpiozero import LED
from time import sleep
Create an LED object on GPIO pin 17
led = LED(17)
Turn the LED on
led.on()
sleep(2) # Keep it on for 2 seconds
Turn the LED off
led.off()
sleep(2) # Keep it off for 2 seconds
Make the LED blink 5 times
led.blink(on_time=2, off_time=1, n=5,background=False) # 1 second on, 1 second off, repeat 5 times
On this page of the site you can watch the video online Blinking an LED using Raspberry Pi 5 and GPIO Zero in Python with a duration of hours minute second in good quality, which was uploaded by the user The Infamous 14 March 2025, share the link with friends and acquaintances, this video has already been watched 136 times on youtube and it was liked by 1 viewers. Enjoy your viewing!