Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
dbrgn
/
leds_button.py
Last active
April 5, 2018 10:05
Star
0
Fork
1
Star
Code
Revisions
2
Forks
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
iC880A Backplane: LED and button example script
Raw
leds_button.py
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
Show hidden characters
import sys
import time
from RPi import GPIO
LED_R = 36
LED_Y = 38
LED_B = 40
BUTTON = 32
# Use the BOARD numbering system
GPIO.setmode(GPIO.BOARD)
# Set up LED pins as output
GPIO.setup(LED_R, GPIO.OUT)
GPIO.setup(LED_Y, GPIO.OUT)
GPIO.setup(LED_B, GPIO.OUT)
# Set up button pin as input with internal pull-up
GPIO.setup(BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Turn on LEDs with 1 second delay
GPIO.output(LED_R, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED_Y, GPIO.HIGH)
time.sleep(1)
GPIO.output(LED_B, GPIO.HIGH)
# Wait for button press
print('Waiting for button press...')
try:
GPIO.wait_for_edge(BUTTON, GPIO.FALLING)
except KeyboardInterrupt:
print('Aborted.')
pass
# Turn off LEDs again with 1 second delay
GPIO.output(LED_R, GPIO.LOW)
time.sleep(1)
GPIO.output(LED_Y, GPIO.LOW)
time.sleep(1)
GPIO.output(LED_B, GPIO.LOW)
# Clean up
GPIO.cleanup()
Copy link
urs8000
commented
Jan 27, 2018
entweder Y oder G verwenden
Sorry, something went wrong.
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
entweder Y oder G verwenden