Arduino compatable USB host shield
Shield plugged into R3 Uno (Not included)
Description:
Fully compatible with Arduino Uno, Duemilanove, and Mega. Allowing you to control the following devices:
HID Compliant devices such as Keyboard, mouse etc.
Compatible with the Android ADK
Digital SLR cameras such as Canon, Nikon, Powershot, etc.
Game console controllers including Wii controller.
Other USB serial communication devices such as GPS, FTDI etc.
Order Yours Here.
Schematic
Example HID USB Keyboard sketch:
Code: Select all
/* FILE: HCMODU0060_USB_Host_Shield_Keyboard_Test
DATE: 05/07/12
VERSION: 0.1
REVISIONS:
05/07/12 Created version 0.1
This is an example of how to use the Hobby Components USB host shield. This
example is to simply tests the shield is operating correctly. To use this
example you will need to connect a SB keyboard to the shield. Open up the
serial monitor window and set the baud rate to 115200. The sketch will report
any key presses to the monitor window.
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of promoting products that
directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR
LACK OF NEGLIGENCE. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE
FOR ANY DAMAGES INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER. */
#include <SPI.h>
#include <Usb.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidescriptorparser.h>
class HIDUniversal2 : public HIDUniversal
{
public:
HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
protected:
virtual uint8_t OnInitSuccessful();
};
uint8_t HIDUniversal2::OnInitSuccessful()
{
uint8_t rcode;
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
ReportDescParser Rpt;
if (rcode = GetReportDescr(0, &Hex))
goto FailGetReportDescr1;
if (rcode = GetReportDescr(0, &Rpt))
goto FailGetReportDescr2;
return 0;
FailGetReportDescr1:
USBTRACE("GetReportDescr1:");
goto Fail;
FailGetReportDescr2:
USBTRACE("GetReportDescr2:");
goto Fail;
Fail:
Serial.println(rcode, HEX);
Release();
return rcode;
}
USB Usb;
USBHub Hub(&Usb);
HIDUniversal2 Hid(&Usb);
UniversalReportParser Uni;
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1)
Serial.println("OSC did not start.");
delay( 200 );
if (!Hid.SetReportParser(0, &Uni))
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
}
void loop()
{
Usb.Task();
}
Library:
Libraries and sample code
Known working snapshot:
FAQ:
I've tried the example sketch but I don't see any response in the monitor window and my USB device doesn't seem to be powered.
On the host shield there is a set solder-able jumpers for configuring various options. Three of these route power from the Arduino to the shield and to the USB host connector. Check that these pads are links with solder:
Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.
Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.