Created
January 5, 2016 18:52
-
-
Save trlewis/09e41f3da3bbe330e85f to your computer and use it in GitHub Desktop.
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
import RPi.GPIO as GPIO | |
import time | |
# set the board mode then print it | |
def set_board(bcm_mode): | |
if bcm_mode: | |
# goes by label of the pin | |
GPIO.setmode(GPIO.BCM) | |
print('using BCM mode') | |
else: | |
# goes by left-to-right, top-to-bottom numbering | |
GPIO.setmode(GPIO.BOARD) | |
print('using BOARD mode') | |
return | |
# the function that does the blinking | |
def blink(pin, blinks): | |
print ('blinking pin ' + str(pin)) | |
for i in range(0, blinks): | |
print('blink ' + str(i + 1)) | |
# GPIO.output(pin, GPIO.HIGH) | |
GPIO.output(pin, True) | |
time.sleep(1) | |
# GPIO.output(pin, GPIO.LOW) | |
GPIO.output(pin, False) | |
time.sleep(1) | |
return | |
# setup GPIO | |
set_board(False) | |
pin_number = 37 | |
GPIO.setup(pin_number, GPIO.OUT) | |
GPIO.output(pin_number, False) | |
# blink the led | |
blink(pin_number, 5) | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment