Skip to content

Commit 94b4e88

Browse files
committed
IOIO example push button
1 parent 89b6d21 commit 94b4e88

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

ioio/samples/button.bas

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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"

0 commit comments

Comments
 (0)