Skip to content

Instantly share code, notes, and snippets.

@MrDMurray
Last active January 10, 2017 10:40
Show Gist options
  • Save MrDMurray/cf4c97c222f0f4986a42c9c0a04bcd17 to your computer and use it in GitHub Desktop.
Save MrDMurray/cf4c97c222f0f4986a42c9c0a04bcd17 to your computer and use it in GitHub Desktop.
STJLOL-DMU Basic GPIO
#the setup
#Reminder: Do you have a resistor in series with your LED? If you don't you will kill the LED and damage the RPi.
import RPi.GPIO as GPIO #lets you use GPIO
from time import sleep #lets you use sleep(2) as a timer for the lights
GPIO.setmode(GPIO.BCM) #tells the program what labeling system to use. We'll use BCM
#because that's what it used on your blue cobbler on your breadboard.
GPIO.setup(17, GPIO.OUT) #tells the pi exactly what GPIO you'll be using
#the code
GPIO.output(17, GPIO.HIGH) #tells the pi to set GPIO-17's voltage to high +5V (ON)
sleep(2) #waits 2 seconds
GPIO.output(17, GPIO.LOW) #tells the pi to set GPIO-17's voltage to low 0V (OFF)
#the cleanup
GPIO.cleanup() #shuts down all GPIO stuff. Takes the keys out of the car so to speak.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment