Solomon Oche Ogonye
Published

Connecting LED with Raspberry pi 4

This tutorial gives us an introduction to the raspberry pi 4 microcontroller.

BeginnerProtip1 hour296
Connecting LED with Raspberry pi 4

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Raspberry Pi - Raspberry Pi 4 usb cable
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian

Story

Read more

Schematics

Circuit Diagram

this is the hook up diagram

Code

pythoncode

Python
import RPi.GPIO as GPIO  # Import Raspberry Pi GPIO library
from time import sleep  # Import sleep function from time module
GPIO.setmode(GPIO.BCM)  # Use BCM numbering
GPIO.setwarnings(False)  # Ingnore all GPIO warnings 
GPIO.setup(23,GPIO.OUT)  # Set GPIO 23 to be an output pin

while True: # Infinity loop
  print "LED is on"  # Display LED is ON on the screen
  GPIO.output(23,GPIO.HIGH)  # Turn on voltage
  sleep(2)  # Delay for 2secs
  print "LED is off"  # Display LED is OFF on the screen
  GPIO.output(23,GPIO.LOW) # Turn off voltage
  sleep(2)  # Delay for 2secs

Credits

Solomon Oche Ogonye

Solomon Oche Ogonye

3 projects • 2 followers

Comments