1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4 <hopobject id="2814" name="2AxisThumbJoystick" prototype="Page" created="1372444995090" lastModified="1387488787005">
5 <hop:parent idref="2471" prototyperef="Page"/>
6 <is_xhtml type="boolean">true</is_xhtml>
7 <http_remotehost>192.91.75.30</http_remotehost>
8 <http_language>en-US,en;q=0.8,fr;q=0.6</http_language>
9 <uri>2AxisThumbJoystick</uri>
10 <http_browser>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36</http_browser>
11 <time type="date">19.12.2013 15:33:07 CST</time>
12 <hopsession>192.91.75.1qb2qdg7e5z6r</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
14 <div id='side-menu' class="t3_sidebar">
\r
15 <ul class="left-menu"><strong>Navigation</strong>
\r
16 <li><a href="/static/side-menu.html">Menu contents</a></li>
\r
19 <div class="t3_content_1"><div id='connect-status'></div><div id="content_child">
\r
20 <h1>Demo: Adafruit 2-Axis Thumb Joystick</h1>
\r
21 <p> The <a href="http://www.adafruit.com/products/512" class="external">Analog
\r
22 2-axis Thumb Joystick</a> allows you to easily mount a PSP/Xbox-like thumb
\r
23 joystick to your project. Using analog pins, the BeagleBone will read and determine
\r
24 both the X and Y axis. The
\r
25 joystick also includes an extra digital input that will let you read the switch.
\r
28 <i>The console will output both the x-axis and y-axis with readings from 0-100, with (50,50) being the center location.</i>
\r
32 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
33 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
35 <pre id="code" class="use-editor" style="height:230px;">
\r
36 var b = require('bonescript');
\r
39 b.analogRead('P9_36', onX);
\r
42 pos.x = parseFloat(x.value * 100).toFixed(2);
\r
43 b.analogRead('P9_38', onY);
\r
47 pos.y = parseFloat(x.value * 100).toFixed(2);
\r
48 console.log(JSON.stringify(pos));
\r
51 <div readonly id='console-output' style="height:100px;"></div>
\r
52 <br></br>
\r
53 <img align="right" width="70%" src="http://beagleboard.org/static/uploads/Joystick1.PNG"/>
\r
54 <br></br>
\r
55 <h2>Build and execute instructions</h2>
\r
57 <li>Connect the "VCC" pin from the joystick to P9_32 of the BeagleBone.</li>
\r
58 <li>Connect the "VER" pin from the joystick to P9_38 of the BeagleBone.</li>
\r
59 <li>Connect the "HOR" pin from the joystick to P9_36 of the BeagleBone.</li>
\r
60 <li>Connect the "SEL" pin from the joystick to P9_42 of the BeagleBone.</li>
\r
61 <li>Connect the "GND" pin from the joystick to P9_34 of the BeagleBone.</li>
\r
62 <li>Click "Run" on the code and it will output both the x and y axis, with 50,50 being the center.</li>
\r
65 <h2>See also</h2>
\r
66 <h3>Related functions</h3>
\r
68 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
69 <li><a href="/Support/BoneScript/analogRead/">analogRead</a></li>
\r
72 <h3>Where to buy</h3>
\r
74 <li> <a href="http://elinux.org/CircuitCo:BeagleBone_Breadboard#Distributors">BreadBoard</a></li>
\r
75 <li><a href="http://www.adafruit.com/products/512">Joystick</a></li>
\r
76 <li><a href="https://www.sparkfun.com/products/11026">Jumper wires</a></li>
\r
79 <h2>See it in action</h2>
\r
80 <iframe width="560" height="315" src="//www.youtube.com/embed/tB3hM5whNN8" frameborder="0" allowfullscreen></iframe></body>
81 <pseudoparent idref="2471" prototyperef="Page"/>
82 <http_referer>http://beagleboard.org/support/BoneScript/2AxisThumbJoystick/edit</http_referer>
83 <http_host>beagleboard.org</http_host>
84 <user>jessica.lynne.callaway@gmail.com</user>