Skip to content

Instantly share code, notes, and snippets.

@jaggedprospect
Created October 1, 2020 15:27
Show Gist options
  • Save jaggedprospect/67c38012d361e5ac7de8c79898c94f08 to your computer and use it in GitHub Desktop.
Save jaggedprospect/67c38012d361e5ac7de8c79898c94f08 to your computer and use it in GitHub Desktop.
A program written in Python to control an LED light from a Raspberry Pi.
#!/usr/bin/env python
#
# blinking_led.py
# @author Nate Heppard
# @date 1 October 2020
import RPi.GPIO as GPIO # Import RasPi GPIO library
from time import sleep # Import sleep function from time module
LED_PIN = 23 # Pin used to control LED
GPIO.setwarnings(False) # Ignore GPIO warnings
GPIO.setmode(GPIO.BCM) # Use BCM GPIO pin numbering
GPIO.setup(LED_PIN, GPIO.OUT, initial=GPIO.LOW) # Set LED_PIN to be an output pin, set initial value to low (off)
# Run the loop forever
while True:
GPIO.output(LED_PIN, GPIO.HIGH) # Set LED_PIN to high (on)
sleep(1) # Sleep for 1 second
GPIO.output(LED_PIN, GPIO.LOW) # Set LED_PIN to low (off)
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment