Created
January 24, 2024 08:52
-
-
Save ditwoo/628667972111ea21865625be55e1a8cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Source: https://thepihut.com/blogs/raspberry-pi-tutorials/27968772-turning-on-an-led-with-your-raspberry-pis-gpio-pins | |
# | |
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library | |
from time import sleep # Import the sleep function | |
pinLED = 27 # LED GPIO Pin LED | |
GPIO.setmode(GPIO.BCM) # Use GPIO pin number | |
GPIO.setwarnings(False) # Ignore warnings in our case | |
GPIO.setup(pinLED, GPIO.OUT) # GPIO pin as output pin | |
while True: # Endless Loop | |
GPIO.output(pinLED, GPIO.HIGH) # Turn on | |
print("LED on") # Prints state to console | |
sleep(1) # Pause 1 second | |
GPIO.output(pinLED, GPIO.LOW) # Turn off | |
print("LED off") # Prints state to console | |
sleep(1) # Pause 1 second |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment