File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ ' PUSH BUTTON
2+ ' ===========
3+ '
4+ ' This example demonstrates how to connect a push button
5+ ' and read the state of this button. If the button is pressed
6+ ' a 0 will be returned otherwise 1
7+ '
8+ ' ---------------
9+ ' PIN10 o----| Push Button |----o GND
10+ ' ---------------
11+ '
12+ ' The push button is connected to pin 10 and to GND of the IOIO board.
13+
14+
15+ import ioio
16+
17+ PIN10 = ioio.openDigitalInput (10 )
18+
19+
20+ print " Wait for connection to IOIO board"
21+ ioio.waitForConnect (10 )
22+ print " Connection established"
23+ print
24+ print " Press button connected to IOIO board or q for quit"
25+
26+ isRunning = true
27+
28+ while (isRunning )
29+
30+ key = inkey ()
31+ if (key == " q" ) then isRunning = false
32+
33+ value = PIN10.read ()
34+
35+ locate (6 ,0 ): print " Button value is: " + value
36+
37+ delay (50 )
38+
39+ wend
40+
41+ print " done"
You can’t perform that action at this time.
0 commit comments