<p>The shield can be purchased at the main site: <ahref="http://www.circuitsathome.com/products-page/arduino-shields">http://www.circuitsathome.com/products-page/arduino-shields</a> or from <ahref="http://tkjelectronics.com/">TKJ Electronics</a>: <ahref="http://shop.tkjelectronics.dk/product_info.php?products_id=43">http://shop.tkjelectronics.dk/product_info.php?products_id=43</a>.</p>
<li>Developers of the <aclass="el"href="class_u_s_b.html">USB</a> Core, <aclass="el"href="class_h_i_d.html">HID</a>, <aclass="el"href="class_f_t_d_i.html">FTDI</a>, <aclass="el"href="class_a_d_k.html">ADK</a>, <aclass="el"href="class_a_c_m.html">ACM</a>, and <aclass="el"href="class_p_l2303.html">PL2303</a> libraries</li>
<li>Developer of the <ahref="#bluetooth-libraries">BTD</a>, <ahref="#bthid-library">BTHID</a>, <ahref="#spp-library">SPP</a>, <ahref="#ps4-library">PS4</a>, <ahref="#ps3-library">PS3</a>, <ahref="#wii-library">Wii</a>, and <ahref="#xbox-library">Xbox</a> libraries</li>
<p>First download the library by clicking on the following link: <ahref="https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip">https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip</a>.</p>
<p>Then uncompress the zip folder and rename the directory to "USB\_Host\_Shield\_20", as any special characters are not supported by the Arduino IDE.</p>
<p>Now open up the Arduino IDE and open "File>Preferences". There you will see the location of your sketchbook. Open that directory and create a directory called "libraries" inside that directory. Now move the "USB\_Host\_Shield\_20" directory to the "libraries" directory.</p>
<p>Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open.</p>
<p>Documentation for the library can be found at the following link: <ahref="http://felis.github.com/USB_Host_Shield_2.0/">http://felis.github.com/USB_Host_Shield_2.0/</a>.</p>
<p>By default serial debugging is disabled. To turn it on simply change <code>ENABLE_UHS_DEBUGGING</code> to 1 in <ahref="settings.h">settings.h</a> like so:</p>
<li>If you are using the Arduino Due, then you must include the Arduino SPI library like so: <code>#include <SPI.h></code> in your .ino file.</li>
</ul>
</li>
<li>Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x)<ul>
<li>Note if you are using the Teensy 3.x you should download this SPI library as well: <ahref="https://github.com/xxxajk/spi4teensy3">https://github.com/xxxajk/spi4teensy3</a>. You should then add <code>#include <spi4teensy3.h></code> to your .ino file.</li>
<p>The <ahref="BTD.cpp">BTD library</a> is a general purpose library for an ordinary Bluetooth dongle. This library make it easy to add support for different Bluetooth services like a PS3 or a Wii controller or <aclass="el"href="class_s_p_p.html">SPP</a> which is a virtual serial port via Bluetooth. Some different examples can be found in the <ahref="examples/Bluetooth">example directory</a>.</p>
<p>The <aclass="el"href="class_b_t_d.html">BTD</a> library also makes it possible to use multiple services at once, the following example sketch is an example of this: <ahref="examples/Bluetooth/PS3SPP/PS3SPP.ino">PS3SPP.ino</a>.</p>
<p>The <ahref="BTHID.cpp">Bluetooth HID library</a> allows you to connect <aclass="el"href="class_h_i_d.html">HID</a> devices via Bluetooth to the <aclass="el"href="class_u_s_b.html">USB</a> Host Shield.</p>
<p>Currently <aclass="el"href="class_h_i_d.html">HID</a> mice and keyboards are supported.</p>
<p>It uses the standard Boot protocol by default, but it is also able to use the Report protocol as well. You would simply have to call <code>setProtocolMode()</code> and then parse <code>HID_RPT_PROTOCOL</code> as an argument. You will then have to modify the parser for your device. See the example: <ahref="examples/Bluetooth/BTHID/BTHID.ino">BTHID.ino</a> for more information.</p>
<p>The <ahref="#ps4-library">PS4 library</a> also uses this class to handle all Bluetooth communication.</p>
<p>For information see the following blog post: <ahref="http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/">http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/</a>.</p>
<p><aclass="el"href="class_s_p_p.html">SPP</a> stands for "Serial Port Profile" and is a Bluetooth protocol that implements a virtual comport which allows you to send data back and forth from your computer/phone to your Arduino via Bluetooth. It has been tested successfully on Windows, Mac OS X, Linux, and Android.</p>
<p>To implement the <aclass="el"href="class_s_p_p.html">SPP</a> protocol I used a Bluetooth sniffing tool called <ahref="http://www.tkjelectronics.com/uploads/PacketLogger.zip">PacketLogger</a> developed by Apple. It enables me to see the Bluetooth communication between my Mac and any device.</p>
<p>The <aclass="el"href="class_p_s4_b_t.html">PS4BT</a> library is split up into the <ahref="PS4BT.h">PS4BT</a> and the <ahref="PS4USB.h">PS4USB</a> library. These allow you to use the Sony PS4 controller via Bluetooth and <aclass="el"href="class_u_s_b.html">USB</a>.</p>
<p>The <ahref="examples/Bluetooth/PS4BT/PS4BT.ino">PS4BT.ino</a> and <ahref="examples/PS4USB/PS4USB.ino">PS4USB.ino</a> examples shows how to easily read the buttons, joysticks, touchpad and IMU on the controller via Bluetooth and <aclass="el"href="class_u_s_b.html">USB</a> respectively. It is also possible to control the rumble and light on the controller and get the battery level.</p>
<p>Simply create the <aclass="el"href="class_p_s4_b_t.html">PS4BT</a> instance like so: <code><aclass="el"href="class_p_s4_b_t.html">PS4BT</a> PS4(&Btd, PAIR);</code> and then hold down the Share button and then hold down the PS without releasing the Share button. The PS4 controller will then start to blink rapidly indicating that it is in paring mode.</p>
<p>It should then automatically pair the dongle with your controller. This only have to be done once.</p>
<p>For information see the following blog post: <ahref="http://blog.tkjelectronics.dk/2014/01/ps4-controller-now-supported-by-the-usb-host-library/">http://blog.tkjelectronics.dk/2014/01/ps4-controller-now-supported-by-the-usb-host-library/</a>.</p>
<p>Also check out this excellent Wiki by Frank Zhao about the PS4 controller: <ahref="http://eleccelerator.com/wiki/index.php?title=DualShock_4">http://eleccelerator.com/wiki/index.php?title=DualShock_4</a> and this Linux driver: <ahref="https://github.com/chrippa/ds4drv">https://github.com/chrippa/ds4drv</a>.</p>
<p>These libraries consist of the <ahref="PS3BT.cpp">PS3BT</a> and <ahref="PS3USB.cpp">PS3USB</a>. These libraries allows you to use a Dualshock 3, Navigation or a Motion controller with the <aclass="el"href="class_u_s_b.html">USB</a> Host Shield both via Bluetooth and <aclass="el"href="class_u_s_b.html">USB</a>.</p>
<p>In order to use your Playstation controller via Bluetooth you have to set the Bluetooth address of the dongle internally to your PS3 Controller. This can be achieved by first plugging in the Bluetooth dongle and wait a few seconds. Now plug in the controller via <aclass="el"href="class_u_s_b.html">USB</a> and wait until the LEDs start to flash. The library has now written the Bluetooth address of the dongle to the PS3 controller.</p>
<p>Finally simply plug in the Bluetooth dongle again and press PS on the PS3 controller. After a few seconds it should be connected to the dongle and ready to use.</p>
<p><b>Note:</b> You will have to plug in the Bluetooth dongle before connecting the controller, as the library needs to read the address of the dongle. Alternatively you could set it in code like so: <ahref="examples/Bluetooth/PS3BT/PS3BT.ino#L20">PS3BT.ino::L20</a>.</p>
<p>For more information about the PS3 protocol see the official wiki: <ahref="https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information">https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information</a>.</p>
<p>A special thanks go to the following people:</p>
<oltype="1">
<li><em>Richard Ibbotson</em> who made this excellent guide: <ahref="http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part">http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part</a></li>
<li><em>Tomoyuki Tanaka</em> for releasing his code for the Arduino <aclass="el"href="class_u_s_b.html">USB</a> Host shield connected to the wiimote: <ahref="http://www.circuitsathome.com/mcu/rc-car-controlled-by-wii-remote-on-arduino">http://www.circuitsathome.com/mcu/rc-car-controlled-by-wii-remote-on-arduino</a></li>
</ol>
<p>Also a big thanks all the people behind these sites about the Motion controller:</p>
<p>The library supports both the original Xbox controller via <aclass="el"href="class_u_s_b.html">USB</a> and the Xbox 360 controller both via <aclass="el"href="class_u_s_b.html">USB</a> and wirelessly.</p>
<h4>Xbox library</h4>
<p>The <ahref="XBOXOLD.cpp">XBOXOLD</a> class implements support for the original Xbox controller via <aclass="el"href="class_u_s_b.html">USB</a>.</p>
<p>All the information are from the following sites:</p>
<p>The library support one Xbox 360 via <aclass="el"href="class_u_s_b.html">USB</a> or up to four Xbox 360 controllers wirelessly by using a <ahref="http://blog.tkjelectronics.dk/wp-content/uploads/xbox360-wireless-receiver.jpg">Xbox 360 wireless receiver</a>.</p>
<p>To use it via <aclass="el"href="class_u_s_b.html">USB</a> use the <ahref="XBOXUSB.cpp">XBOXUSB</a> library or to use it wirelessly use the <ahref="XBOXRECV.cpp">XBOXRECV</a> library.</p>
<p>The <ahref="Wii.cpp">Wii</a> library support the Wiimote, but also the Nunchuch and Motion Plus extensions via Bluetooth. The Wii U Pro Controller is also supported via Bluetooth.</p>
<p>The Wii IR camera can also be used, but you will have to activate the code for it manually as it is quite large. Simply set <code>ENABLE_WII_IR_CAMERA</code> to 1 in <ahref="settings.h">settings.h</a>.</p>
<p>The <ahref="examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino">WiiIRCamera.ino</a> example shows how it can be used.</p>
<li>The old library created by <em>Tomoyuki Tanaka</em>: <ahref="https://github.com/moyuchin/WiiRemote_on_Arduino">https://github.com/moyuchin/WiiRemote_on_Arduino</a> also helped a lot.</li>
<li>Try to connect a external power supply to the Arduino - this solves the problem in most cases.</li>
<li>You can also use a powered hub between the device and the <aclass="el"href="class_u_s_b.html">USB</a> Host Shield. You should then include the <aclass="el"href="class_u_s_b.html">USB</a> hub library: <code>#include <<aclass="el"href="usbhub_8h.html">usbhub.h</a>></code> and create the instance like so: <code><aclass="el"href="class_u_s_b_hub.html">USBHub</a> Hub1(&Usb);</code>. </li>