Demo: Adafruit 2-Axis Thumb Joystick
The Analog 2-axis Thumb Joystick allows you to easily mount a PSP/Xbox-like thumb joystick to your project. Using analog pins, the BeagleBone will read and determine both the X and Y axis. The joystick also includes an extra digital input that will let you read the switch.
The console will output both the x-axis and y-axis with readings from 0-100, with (50,50) being the center location.Example
var b = require('bonescript'); var pos = {}; b.analogRead('P9_36', onX); function onX(x) { pos.x = parseFloat(x.value * 100).toFixed(2); b.analogRead('P9_38', onY); } function onY(x) { pos.y = parseFloat(x.value * 100).toFixed(2); console.log(JSON.stringify(pos)); }
Build and execute instructions
- Connect the "VCC" pin from the joystick to P9_32 of the BeagleBone.
- Connect the "VER" pin from the joystick to P9_38 of the BeagleBone.
- Connect the "HOR" pin from the joystick to P9_36 of the BeagleBone.
- Connect the "SEL" pin from the joystick to P9_42 of the BeagleBone.
- Connect the "GND" pin from the joystick to P9_34 of the BeagleBone.
- Click "Run" on the code and it will output both the x and y axis, with 50,50 being the center.
See also
Related functions
Where to buy
See it in action
Last updated by jessica.lynne.callaway on Thu Dec 19 2013 21:33:07 GMT-0000 (UTC).