<p>Project main web site is: <ahref="https://chome.nerpa.tech/arduino_usb_host_shield_projects/">https://chome.nerpa.tech/arduino_usb_host_shield_projects/</a>.</p>
<p>The shield can be purchased 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, HID, <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="#ps5-library">PS5</a>, <ahref="#ps4-library">PS4</a>, <ahref="#ps3-library">PS3</a>, <ahref="#wii-library">Wii</a>, <ahref="#xbox-library">Xbox</a>, and <ahref="#ps-buzz-library">PSBuzz</a> libraries</li>
<p>First install Arduino IDE version 1.6.2 or newer, then simply use the Arduino Library Manager to install the library.</p>
<p>Please see the following page for instructions: <ahref="http://www.arduino.cc/en/Guide/Libraries#toc3">http://www.arduino.cc/en/Guide/Libraries#toc3</a>.</p>
<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>For more information visit the following sites: <ahref="http://arduino.cc/en/Guide/Libraries">http://arduino.cc/en/Guide/Libraries</a> and <ahref="https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use">https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use</a>.</p>
<p>Documentation for the library can be found at the following link: <ahref="https://felis.github.io/USB_Host_Shield_2.0/">https://felis.github.io/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>Note that the Intel Galileo uses pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the <ahref="https://chome.nerpa.tech/usb-host-shield-hardware-manual">hardware manual</a> for more information.</li>
<li>Note native <aclass="el"href="class_u_s_b.html">USB</a> host is not supported on any of these platforms. You will have to use the shield for now.</li>
<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>
<li>Currently the <ahref="http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF262063">NUCLEO-F446RE</a> is supported featuring the STM32F446. Take a look at the following example code: <ahref="https://github.com/Lauszus/Nucleo_F446RE_USBHost">https://github.com/Lauszus/Nucleo_F446RE_USBHost</a>.</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 HID devices via Bluetooth to the <aclass="el"href="class_u_s_b.html">USB</a> Host Shield.</p>
<p>Currently HID 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 PS5 library is split up into the <ahref="PS5BT.h">PS5BT</a> and the <ahref="PS5USB.h">PS5USB</a> library. These allow you to use the Sony PS5 controller via Bluetooth and <aclass="el"href="class_u_s_b.html">USB</a>.</p>
<p>The <ahref="examples/Bluetooth/PS5BT/PS5BT.ino">PS5BT.ino</a> and <ahref="examples/PS5USB/PS5USB.ino">PS5USB.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, lightbar, microphone LED and player LEDs on the controller. Furthermore the new haptic trigger effects are also supported.</p>
<p>To pair with the PS5 controller via Bluetooth you need create the <aclass="el"href="class_p_s5_b_t.html">PS5BT</a> instance like so: <code><aclass="el"href="class_p_s5_b_t.html">PS5BT</a> PS5(&Btd, PAIR);</code> and then hold down the Create button and then hold down the PS without releasing the Create button. The PS5 controller will then start to blink blue indicating that it is in pairing mode.</p>
<p>It should then automatically pair the dongle with your controller. This only have to be done once.</p>
<p>Thanks to Joseph Duchesne for the initial <aclass="el"href="class_u_s_b.html">USB</a> code.</p>
<p>The driver is based on the official Sony driver for Linux: <ahref="https://patchwork.kernel.org/project/linux-input/cover/20201219062336.72568-1-roderick@gaikai.com/">https://patchwork.kernel.org/project/linux-input/cover/20201219062336.72568-1-roderick@gaikai.com/</a>.</p>
<p>Also thanks to Ludwig Füchsl's <ahref="https://github.com/Ohjurot/DualSense-Windows">https://github.com/Ohjurot/DualSense-Windows</a> for his work on the haptic triggers.</p>
<p>The PS4 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 pairing 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>Several guides on how to use the PS4 library has been written by Dr. James E. Barger and are available at the following link: <ahref="https://sites.google.com/view/crosswaystation/ps4-tutorials">https://sites.google.com/view/crosswaystation/ps4-tutorials</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>
<li><em>Richard Ibbotson</em> who made this excellent guide: <ahref="http://chome.nerpa.tech/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part">http://chome.nerpa.tech/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://chome.nerpa.tech/mcu/rc-car-controlled-by-wii-remote-on-arduino">http://chome.nerpa.tech/mcu/rc-car-controlled-by-wii-remote-on-arduino</a></li>
<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>A Xbox ONE controller is supported via <aclass="el"href="class_u_s_b.html">USB</a> in the <ahref="XBOXONE.cpp">XBOXONE</a> class. It is heavily based on the 360 library above. In addition to cross referencing the above, information on the protocol was found at:</p>
<p>A Xbox ONE controller is supported via Bluetooth in the <ahref="XBOXONESBT.cpp">XBOXONESBT</a> class.</p>
<p>Special thanks to <ahref="https://github.com/HisashiKato">HisashiKato</a> for his help: <ahref="https://github.com/felis/USB_Host_Shield_2.0/issues/252#issuecomment-716912362">https://github.com/felis/USB_Host_Shield_2.0/issues/252#issuecomment-716912362</a>.</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 and Wii Balance Board are also supported via Bluetooth.</p>
</div><!-- fragment --><p>And then press 1 & 2 at once on the Wiimote or the SYNC buttons if you are using a Wii U Pro Controller or a Wii Balance Board.</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>
<p>This library implements support for the Playstation Buzz controllers via <aclass="el"href="class_u_s_b.html">USB</a>.</p>
<p>It is essentially just a wrapper around the <ahref="hiduniversal.cpp">HIDUniversal</a> which takes care of the initializing and reading of the controllers. The <ahref="PSBuzz.cpp">PSBuzz</a> class simply inherits this and parses the data, so it is easy for users to read the buttons and turn the big red button on the controllers on and off.</p>
<p>The example <ahref="examples/PSBuzz/PSBuzz.ino">PSBuzz.ino</a> shows how one can do this with just a few lines of code.</p>
<p>More information about the controller can be found at the following sites:</p>
<p>HID devices are also supported by the library. However these require you to write your own driver. A few example are provided in the <ahref="examples/HID">examples/HID</a> directory. Including an example for the <ahref="examples/HID/SRWS1/SRWS1.ino">SteelSeries SRW-S1 Steering Wheel</a>.</p>
<h3><ahref="usbh_midi.cpp">MIDI Library</a></h3>
<p>The library support MIDI devices. You can convert <aclass="el"href="class_u_s_b.html">USB</a> MIDI keyboard to legacy serial MIDI.</p>
<p>The shield is using SPI for communicating with the MAX3421E <aclass="el"href="class_u_s_b.html">USB</a> host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board.</p>
<p>Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else than SPI communication!</p>
<p>Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin.</p>
<p>After that you need modify the following entry in <ahref="UsbCore.h">UsbCore.h</a>:</p>
</div><!-- fragment --><p>See the "Interface modifications" section in the <ahref="https://chome.nerpa.tech/usb-host-shield-hardware-manual">hardware manual</a> for more information.</p>
<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>
<li>This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following <ahref="https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles">list</a> for tested working dongles.</li>