Uses a Sparkfun Thumb Joystick to control the X and Y coordinate returned from the mbed device acting as a HID based absolute mouse.
Diff: main.cpp
- Revision:
- 2:ceb3218c3229
- Parent:
- 0:b2c327d045a2
--- 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);