Created
June 15, 2016 20:20
-
-
Save frangucc/4804e1fb3a6f6f541ed35c1200a13217 to your computer and use it in GitHub Desktop.
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 GPIO ## Import GPIO Library | |
import time ## Import 'time' library. Allows us to use 'sleep' | |
GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering | |
GPIO.setup(7, GPIO.OUT) ## Setup GPIO pin 7 to OUT | |
## Define function named Blink() | |
def Blink(numTimes, speed): | |
for i in range(0,numTimes): ## Run loop numTimes | |
print "Iteration " + str(i+1) ##Print current loop | |
GPIO.output(7, True) ## Turn on GPIO pin 7 | |
time.sleep(speed) ## Wait | |
GPIO.output(7, False) ## Switch off GPIO pin 7 | |
time.sleep(speed) ## Wait | |
print "Done" ## When loop is complete, print "Done" | |
GPIO.cleanup() | |
## Prompt user for input | |
iterations = raw_input("Enter the total number of times to blink: ") | |
speed = raw_input("Enter the length of each blink in seconds: ") | |
## Start Blink() function. Convert user input from strings to numeric data types and pass to Blink() as parameters | |
Blink(int(iterations),float(speed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment