Download Print this page

Parallax 27808 Quick Start Manual page 4

Gimbal joystick with adapter

Advertisement

Propeller C Example Program for Activity Board
The example code from the Propeller C Tutorials series, written for a smaller joystick, works fine with the
Gimbal Joystick wiring example shown above by simply updating the ADC channels used. This example
program and the libraries it uses are included with the SimpleIDE software. Download for Windows or
Mac from http://learn.parallax.com/propeller-c.
In the SimpleIDE software, browse to Learn>Examples>Devices>Joystick, and open the project. Update
the first two lines in the while(1) loop to use ADC channels 1 and 0 as shown in bold below, instead of 2
and 3.
/*
Joystick.c
http://learn.parallax.com/propeller-c-simple-devices/joystick
*/
#include "adcDCpropab.h"
#include "simpletools.h"
int main()
{
pause(1000);
adc_init(21, 20, 19, 18);
float lrV, udV;
while(1)
{
udV = adc_volts(0);
lrV = adc_volts(1);
putChar(HOME);
print("Up/Down = %.2f V %c\n", udV, CLREOL);
print("Left/Right = %.2f V %c\n", lrV, CLREOL); // Display voltage
pause(100);
}
}
Click the Run with Terminal button. The SimpleIDE Terminal will show the voltage values returned for
each axis. As you move the joystick around, you will see the values change. These values may be used
as-is, or scaled to appropriate input values for the device you would like to control with the joystick.
Copyright © Parallax Inc.
Gimbal Joystick with Adapter (#27808)
// Include adcDCpropab
// Include simpletools
// Main function
// Wait 1 s for Terminal app
// CS=21, SCL=20, DO=19, DI=18
// Voltage variables
// Loop repeats indefinitely
// Update to Check A/D 1
// Update to Check A/D 0
// Cursor -> top-left "home"
// Display voltage
// Wait 1/10 s
v1.2 11/13/2019 Page 4 of 9

Advertisement

loading