How to blink an LED using Pi board




In this tutorial,we will learn how to blink an led using a Pi board.

Hardware required:

1.Pi board-any model

2.Jumpers

3.Led

4.Breadboard


1.Hardware

Circuit -pi 4 board and led

BLACK =Ground (39)

RED=Pin 16 (36)


To know about your gpio pin location go to terminal and type

pinout

2.Software

After that,move on to the coding part
cd                              # to move to the home directory 
sudo nano Project1.py          #to create a python file named Project1.py

Copy and paste this coding in Project1.py

from gpiozero import LED
from time import sleep

led = LED (16)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)
    
    

Press Ctrl+X to exit and press Y,Enter to save it

python Project1.py      #You can see your led blinking,press Ctrl+Z to stop it

3.Output

Leave a comment

Knowledge is Power

Design a site like this with WordPress.com
Get started