Uses a Sparkfun Thumb Joystick to control the X and Y coordinate returned from the mbed device acting as a HID based absolute mouse.
Revision 2:ceb3218c3229, committed 2011-12-07
- Comitter:
- AdamGreen
- Date:
- Wed Dec 07 07:27:31 2011 +0000
- Parent:
- 1:df7a5706802a
- Commit message:
- Modified to work with analog thumbstick and updated to latest mbed libraries.
Changed in this revision
USBDevice.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r df7a5706802a -r ceb3218c3229 USBDevice.lib --- a/USBDevice.lib Fri Nov 18 06:26:29 2011 +0000 +++ b/USBDevice.lib Wed Dec 07 07:27:31 2011 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/USBDevice/#ef8c6751b185 +http://mbed.org/users/samux/code/USBDevice/#f3327d71595f
diff -r df7a5706802a -r ceb3218c3229 main.cpp --- a/main.cpp Fri Nov 18 06:26:29 2011 +0000 +++ b/main.cpp Wed Dec 07 07:27:31 2011 +0000 @@ -12,9 +12,28 @@ See the License for the specific language governing permissions and limitations under the License. */ -/* Uses two 10k potentiometers conntected to AnalogIn pins 15 and 16 to - control the X and Y coordinate returned from the mbed device which is - acting as HID based absolute mouse. +/* Uses a Sparkfun Thumb Joystick to control the X and Y coordinate returned + from the mbed device acting as a HID based absolute mouse. + + More information about the analog joystick and associated breakout board can + be found at the following URL: http://www.sparkfun.com/products/10433 + + Connections + +-------------------+---------------+ + | Joystick Breakout | mbed | + | VCC | pin 40 - VOUT | + | VERT | pin 15 - p15 | + | HORZ | pin 16 - p16 | + | SEL | Not Connected | + | GND | pin 1 - GND | + +-------------------+---------------+ + + The following notebook page shows how to connect a SparkFun USB breakout + board to mbed pin 31 (D+) & pin 32 (D-). + http://mbed.org/users/romilly/notebook/unboxing-the-lpc11u24/ + + Notebook page describing this program can be found here: + http://mbed.org/users/romilly/notebook/unboxing-the-lpc11u24/ */ #include <mbed.h> #include <USBMouse.h> @@ -30,7 +49,7 @@ while (1) { float AnalogXReading = AnalogX.read(); - float AnalogYReading = AnalogY.read(); + float AnalogYReading = 1.0f - AnalogY.read(); uint16_t X = X_MIN_ABS + (uint16_t)(Width * AnalogXReading); uint16_t Y = Y_MIN_ABS + (uint16_t)(Height * AnalogYReading);