In this video, I will show you how to Blink an LED with Raspberry Pi using Python program i.e. turn on the LED for some duration and turn off the LED for some duration. RPi.GPIO Library and time module has been used in python programming to control the LED.
If you don’t have RPi.GPIO library then type the following commands in the Terminal to install it in your raspberry.
sudo apt-get update
sudo apt-get install rpi.gpio
The Components required are :
• Raspberry Pi (Any Model 2, 3, 4)
• Keyboard
• Mouse
• Monitor
• SD Card (Min. 16 GB)
• Breadboard
• GPIO Extension Board
• GPIO Extension Cable
• LED
• 220 Ohm Resistor
• Jumper Wires
Python Program :
import RPi.GPIO as GPIO
import time
Variables
LED_Pin_No = 17
Main_Loop_Condition = True
Main Function
def Main():
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_Pin_No, GPIO.OUT)
GPIO.output(LED_Pin_No, GPIO.LOW)
while Main_Loop_Condition:
GPIO.output(LED_Pin_No, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED_Pin_No, GPIO.LOW)
time.sleep(1)
Function to Exit and release GPIO Pins
def Exit():
GPIO.cleanup()
Main_Loop_Condition = False
exit()
Main Program
if _name_ == "__main__":
try:
Main()
except KeyboardInterrupt:
Exit()
END ##
If you like this video, please press the like button and subscribe to my channel...
Thank You
En esta página del sitio puede ver el video en línea Blinking an LED using Raspberry Pi and Python Programming de Duración hora minuto segunda en buena calidad , que subió el usuario Innovation with Robotics 01 enero 1970, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 67 veces y le gustó 5 a los espectadores. Disfruta viendo!