<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Somatosensory_game_controller</id>
		<title>Somatosensory game controller - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Somatosensory_game_controller"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Somatosensory_game_controller&amp;action=history"/>
		<updated>2026-04-22T16:28:36Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Somatosensory_game_controller&amp;diff=10910&amp;oldid=prev</id>
		<title>1304410487@qq.com：Created page with &quot;{{Language| Somatosensory Game Controller }} {| style=&quot;width: 800px;&quot; |- | ==Objective== You can control games by the somatosensory analog keyboard--W, A, S and D.   ==Princip...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Somatosensory_game_controller&amp;diff=10910&amp;oldid=prev"/>
				<updated>2015-10-22T02:57:18Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language| Somatosensory Game Controller }} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== You can control games by the somatosensory analog keyboard--W, A, S and D.   ==Princip...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language| Somatosensory Game Controller }}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
You can control games by the somatosensory analog keyboard--W, A, S and D. &lt;br /&gt;
&lt;br /&gt;
==Principle==&lt;br /&gt;
Detect game controller's motion change with three-axis acceleration sensor MPU6050 and then use Microduino-CoreUSB analog function to simulate keys of W, A, S and D. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|Module||Number||Function&lt;br /&gt;
|-&lt;br /&gt;
|[[Microduino-CoreUSB]]||1||Core board&lt;br /&gt;
|-&lt;br /&gt;
|[[Microduino-10DOF]]||1||Vector sensor module &lt;br /&gt;
|}&lt;br /&gt;
 [[File: Motion_handle.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Hardware Buildup==&lt;br /&gt;
* Setup 1：Connect CoreUSB to the computer, open program examples, select the right board and serial port, then download the program. &lt;br /&gt;
[https://github.com/Microduino/Microduino_Tutorials/tree/master/MCookie_Tutorial/Motion_Handle Motion_Handle]&lt;br /&gt;
*Setup 2：Stack CoreUSB and 10DOF. &lt;br /&gt;
[[File:CoreUSB_10DOF.jpg|600px|center|thumb]]&lt;br /&gt;
*Setup 3：Connect CoreUSB to the computer which will identify a keyboard and display &amp;quot; HID Keyboard Device &amp;quot; in the device manager. &lt;br /&gt;
[[file:Microduino-sensorhub_rule.JPG|thumb|800px|center]]&lt;br /&gt;
[[File:HID_Keyboard_Device.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Software Debugging==&lt;br /&gt;
Code Description &lt;br /&gt;
*Control variable initialization: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
MPU6050 accelgyro;   //Three-axis acceleration sensor &lt;br /&gt;
int ax,ay,az;       //Three-axis acceleration sensor variable&lt;br /&gt;
float Ax,Ay,Az;&lt;br /&gt;
&lt;br /&gt;
void setup(){&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  Keyboard.begin();      //Keyboard simulation begins.&lt;br /&gt;
  Serial.println(&amp;quot;Initializing I2C devices...&amp;quot;);&lt;br /&gt;
  accelgyro.initialize();     //Accelerator initializes. &lt;br /&gt;
    // verify connection &lt;br /&gt;
  Serial.println(&amp;quot;Testing device connections...&amp;quot;);&lt;br /&gt;
  Serial.println(accelgyro.testConnection() ? &amp;quot;MPU6050 connection successful&amp;quot; : &amp;quot;MPU6050 connection failed&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
*Judge the controller's motion status. Moving towards left, right, front and back corresponds to the key A, D, W and S respectively. &lt;br /&gt;
 &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   void loop() {&lt;br /&gt;
    accelgyro.getAcceleration(&amp;amp;ax, &amp;amp;ay, &amp;amp;az); &lt;br /&gt;
    Ax = ax/16384.00;         //Calculate X-axis's acceleration &lt;br /&gt;
    Ay = ay/16384.00;         // Calculate Y-axis's acceleration&lt;br /&gt;
    Az = az/16384.00;         // Calculate Z-axis's acceleration&lt;br /&gt;
    if(Ay &amp;gt;= 0.6 )            //Turn the controller leftwards &lt;br /&gt;
    {&lt;br /&gt;
      Keyboard.press('A');    //Keyboard 'A'     &lt;br /&gt;
    }&lt;br /&gt;
    else if(Ay &amp;lt;= -0.6)       //Turn the controller rightwards &lt;br /&gt;
    {&lt;br /&gt;
      Keyboard.press('D');   //Keyboard 'D' &lt;br /&gt;
    }&lt;br /&gt;
    else if(Ax &amp;gt;= 0.6)       //Turn forward &lt;br /&gt;
    {&lt;br /&gt;
      Keyboard.press('S');   //Keyboard 'S' &lt;br /&gt;
    }&lt;br /&gt;
    else if(Ax &amp;lt;= -0.6)     //Turn backward &lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
       Keyboard.press('W'); //Keyboard 'W'&lt;br /&gt;
    } &lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
        Keyboard.releaseAll();  //Release the key &lt;br /&gt;
    }   &lt;br /&gt;
    delay(200); &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
Open NotePad on the computer and connect to Coreusb. By turning the controller leftwards, you'll see the character &amp;quot;A&amp;quot; is printed on the NotePad while by turning the controller back to the original position and you'll see the NotePad stops printing. That also works for the other keys. &lt;br /&gt;
&lt;br /&gt;
==Video==&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>1304410487@qq.com</name></author>	</entry>

	</feed>