Turning On LED using Raspberry Pi with Python Program

Pubblicato il: 26 novembre 2021
sul canale di: Innovation with Robotics
448
17

In this video I will show you how to control an LED i.e. turn on and turn off the LED with Raspberry Pi using Python program. RPi.GPIO Library has been used in python program.

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

The Python Program is as under:

import RPi.GPIO as GPIO

Variables
LED_Pin_No = 17
Main_Loop_Condition = True

Main Function
def Main():
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIn_No, GPIO.OUT)

while Main_Loop_Condition:
For turning on the LED
GPIO.output(LED_Pin_No, GPIO.HIGH)
For turning off the LED
GPIO.output(LED_Pin_No, GPIO.LOW)

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


In questa pagina del sito puoi guardare il video online Turning On LED using Raspberry Pi with Python Program della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Innovation with Robotics 26 novembre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 448 volte e gli è piaciuto 17 spettatori. Buona visione!