Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pls-pnv
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
plaasio
pls-pnv
Commits
d7c3f4a8
Commit
d7c3f4a8
authored
Jan 29, 2020
by
plaasio
👷🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update btns.py
parent
4190a0c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
btns.py
btns.py
+22
-7
No files found.
btns.py
View file @
d7c3f4a8
import
RPi.GPIO
as
GPIO
# Import Raspberry Pi GPIO library
def
button_callback
(
channel
):
print
(
"Button was pushed!"
)
GPIO
.
setwarnings
(
False
)
# Ignore warning for now
def
no_callback
(
channel
):
print
(
"no Button was pushed!"
)
def
down_callback
(
channel
):
print
(
"down Button was pushed!"
)
def
up_callback
(
channel
):
print
(
"up Button was pushed!"
)
def
yes_callback
(
channel
):
print
(
"yes Button was pushed!"
)
GPIO
.
setwarnings
(
True
)
# Ignore warning for now
GPIO
.
setmode
(
GPIO
.
BOARD
)
# Use physical pin numbering
GPIO
.
setup
(
23
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO
.
add_event_detect
(
23
,
GPIO
.
RISING
,
callback
=
button_callback
)
# Setup event on pin 10 rising edge
message
=
input
(
"Press enter to quit
\n\n
"
)
# Run until someone presses enter
GPIO
.
cleanup
()
\ No newline at end of file
GPIO
.
setup
(
13
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# Set pin 22 to be an input pin and set initial value to be pulled low (off)
GPIO
.
setup
(
15
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# Set pin 23 to be an input pin and set initial value to be pulled low (off)
GPIO
.
setup
(
16
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# Set pin 24 to be an input pin and set initial value to be pulled low (off)
GPIO
.
setup
(
18
,
GPIO
.
IN
,
pull_up_down
=
GPIO
.
PUD_DOWN
)
# Set pin 26 to be an input pin and set initial value to be pulled low (off)
GPIO
.
add_event_detect
(
13
,
GPIO
.
RISING
,
callback
=
no_callback
)
# Setup event on pin 22 rising edge
GPIO
.
add_event_detect
(
15
,
GPIO
.
RISING
,
callback
=
down_callback
)
# Setup event on pin 23 rising edge
GPIO
.
add_event_detect
(
16
,
GPIO
.
RISING
,
callback
=
up_callback
)
# Setup event on pin 24 rising edge
GPIO
.
add_event_detect
(
18
,
GPIO
.
RISING
,
callback
=
yes_callback
)
# Setup event on pin 26 rising edge
#message = input("Press enter to quit\n\n") # Run until someone presses enter
#GPIO.cleanup()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment