Copyright © Parallax Inc.
Gimbal Joystick with Adapter (#27808)
v1.2 11/13/2019 Page 5 of 9
Spin Example Program for Propeller Board of Education
Download and unzip the Gimbal Joystick Example Spin Code (search 27807 at
). Open
the program
PropBOE_joystick_demo.spin
with the Propeller Tool (a free download from
www.parallax.com/propellertool
):
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
pst : "Parallax Serial Terminal"
adc : "PropBOE ADC"
joy : "joystick"
PUB start | rawh, rawv
pst.start(9600)
joy.setup(0, 400, 500, 600, 50, -500, 500)
joy.setup(1, 400, 500, 600, 0, 0, 1000)
repeat
rawh := adc.in(0)
rawv := adc.in(1)
pst.str(string(1, " Raw Joystick", 11, 13, "Horiz:", 14, 7))
pst.dec(rawh)
pst.str(string(" ", 14, 15))
pst.dec(joy.value(0, rawh))
pst.str(string(11, 13, "Vert:", 14, 7))
pst.dec(rawv)
pst.str(string(" ", 14, 15))
pst.dec(joy.value(1, rawv))
pst.char(11)
Load the program using the
F10
key, and open the Parallax Serial Terminal via the
F12
key. You should
see a display that looks like this:
As you move the joystick around, the values in the display will change to show its position. The
Raw
values are the numbers read from the ADC. The joystick.spin object scales the raw ADC values to
produce the
Joystick
values. In this example, the horizontal values range from –500 to +500 and