Hi. I am using Honeywell barcode scanner for a automation project...I used a usb host sheild (sparkfun) too along with arduino uno.....But when i upload my code no outpot from scanner is coming. Even scanner laser light is also not available. Pls help to find flaws of mine. i used the bellow code.
#include <hid.h> //Add to Oleg Mazurov code to Bar Code Scanner
#include <hiduniversal.h> //Add to Oleg Mazurov code to Bar Code Scanner
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <hidboot.h>
#define DISPLAY_WIDTH 16
USB Usb;
USBHub Hub(&Usb); //I enable this line
HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);
class KbdRptParser : public KeyboardReportParser
{
void PrintKey(uint8_t mod, uint8_t key); // Add this line to print character in ASCII
protected:
virtual void OnKeyDown (uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key);
};
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
uint8_t c = OemToAscii(mod, key);
if (c)
OnKeyPressed(c);
}
/* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key)
{
Serial.print( (char)key ); //Add char to print correct number in ASCII
};
KbdRptParser Prs;
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}
Keyboard.SetReportParser(0, (HIDReportParser*)&Prs); //Here I change "Keyboard" for "Hid"
}
void loop()
{
Usb.Task();
}