Created
September 10, 2017 08:41
-
-
Save gthoppae/0aaee3cf638e950dcfadaa9c2f9daba0 to your computer and use it in GitHub Desktop.
Raspberry Pi GPIO exercise - blink LED 5 times
This file contains hidden or 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
import RPi.GPIO as g | |
import time | |
from subprocess import call | |
call('clear') | |
# set the board | |
g.setmode(g.BOARD) | |
# set up PIN 12 for output | |
g.setup(12,g.OUT) | |
# switch off LED | |
#g.output(12,0) | |
print "Ok, I will make the LED blink 5 times" | |
time.sleep(3) | |
for i in range(0,5): | |
print "switching on" | |
# switch on LED | |
g.output(12,1) | |
# time out after 1 seconds | |
time.sleep(0.5) | |
print "switching off" | |
# switch off LED | |
g.output(12,0) | |
# time out after 1 seconds | |
time.sleep(0.5) | |
print "Done!" | |
# set the GPIO pins back to normal | |
g.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment