![Joy-it MOTOPI Manual Download Page 8](http://html1.mh-extra.com/html/joy-it/motopi/motopi_manual_2027334008.webp)
www.joy
-
it.net
Pascalstr. 8 47506 Neukirchen
-
Vluyn
8. CODE EXAMPLE TO USE THE DIGITAL CONNECTIONS
Consecutively, you have a short code example for controlling the digital
connections. For that, we use the
LK
-
Joystick
with a
LK
-
Cable
-
20
from
our LinkerKit series.
Note that if not all connection are taken, the free pins can issue false
values.
import
spidev
import
time
import
sys
spi = spidev.SpiDev()
spi.open(
0
,
0
)
spi.max_speed_hz =
2000000
def
readadc
(adcnum):
if
adcnum >
7
or
adcnum <
0
:
return
-
1
r = spi.xfer2([
1
,
8
+adcnum <<
4
,
0
])
adcout = ((r[
1
] &
3
) <<
8
)+r[
2
]
return
adcout
while
True
:
if
len
(sys.argv) >
1
:
for
i
in
range
(
len
(sys.argv)):
if
i ==
0
:
"_______________________________________\n"