File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ from adafruit_debouncer import Debouncer
2
+ from adafruit_pybadger import pybadger
3
+
4
+ b_btn = Debouncer (lambda : pybadger .button .b == 0 )
5
+ a_btn = Debouncer (lambda : pybadger .button .a == 0 )
6
+ up_btn = Debouncer (lambda : pybadger .button .up == 0 )
7
+ down_btn = Debouncer (lambda : pybadger .button .down == 0 )
8
+ left_btn = Debouncer (lambda : pybadger .button .left == 0 )
9
+ right_btn = Debouncer (lambda : pybadger .button .right == 0 )
10
+
11
+ while True :
12
+ b_btn .update ()
13
+ a_btn .update ()
14
+ up_btn .update ()
15
+ down_btn .update ()
16
+ right_btn .update ()
17
+ left_btn .update ()
18
+
19
+ if b_btn .fell :
20
+ print ("B pressed" )
21
+ if b_btn .rose :
22
+ print ("B released" )
23
+
24
+ if a_btn .fell :
25
+ print ("A pressed" )
26
+ if a_btn .rose :
27
+ print ("A released" )
28
+
29
+ if up_btn .fell :
30
+ print ("UP pressed" )
31
+ if up_btn .rose :
32
+ print ("UP released" )
33
+
34
+ if down_btn .fell :
35
+ print ("DOWN pressed" )
36
+ if down_btn .rose :
37
+ print ("DOWN released" )
38
+
39
+ if right_btn .fell :
40
+ print ("RIGHT pressed" )
41
+ if right_btn .rose :
42
+ print ("RIGHT released" )
43
+
44
+ if left_btn .fell :
45
+ print ("LEFT pressed" )
46
+ if left_btn .rose :
47
+ print ("LEFT released" )
You can’t perform that action at this time.
0 commit comments