-
-
Save daniel-obrien/0b7790b777462af8c83eed59a1f8897a to your computer and use it in GitHub Desktop.
STJLOL-DMU Basic GPIO
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
#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