USB HOST SHIELD - BAR CODE SCANNER - PROBLEM

Hello,
I want to make a project barcode scanning device, in which barcode scanner scans the barcode then sends it to mobile app.
The basic flow is as follows:
Barcode scanner → USB host sheld → Arduino Mega 2560 → Bluetooth module HC-05 → Mobile app.
I took the code from www.electroingenio.com
But there is some error which i can’t understand so plz help.

ERROR: cannot declare variable ‘hub’ to be of abstract type ‘USB hub’

CODE:

/* ****************************** www.electroingenio.com **********************************

/*

USB BAR CODE SCANNER USB HOST SHIELD TO DISPLAY BARCODE ON LCD
ADAPTED USING OLEG MAZUROV ARDUINO CODE

The circuit:

  • LCD RS pin to digital pin 7
  • LCD Enable pin to digital pin 6
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • 10K resistor:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)

*/
#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 <LiquidCrystal.h>
#include <avr/pgmspace.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <hidboot.h>
#define DISPLAY_WIDTH 16

//initialize the LCD library with the numbers of the interface pins//

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

USB Usb;
USBHub Hub(&Usb); //I enable this line
HIDUniversal Hid(&Usb); //Add this line so that the barcode scanner will be recognized, I use “Hid” below
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)
{
static uint32_t next_time = 0; //watchdog
static uint8_t current_cursor = 0; //tracks current cursor position

if( millis() > next_time ) {
lcd.clear();
current_cursor = 0;
delay( 5 ); //LCD-specific
lcd.setCursor( 0,0 );
}//if( millis() > next_time …

next_time = millis() + 200; //reset watchdog

if( current_cursor++ == ( DISPLAY_WIDTH + 1 )) { //switch to second line if cursor outside the screen
lcd.setCursor( 0,1 );
}

Serial.print( (char)key ); //Add char to print correct number in ASCII
lcd.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.”);
}

delay( 200 );

Hid.SetReportParser(0, (HIDReportParser*)&Prs); //Here I change “Keyboard” for “Hid”
// set up the LCD’s number of columns and rows:
lcd.begin(DISPLAY_WIDTH, 2);
lcd.clear();
lcd.noAutoscroll();
lcd.print(“Ready”);
delay( 200 );
}

void loop()
{
Usb.Task();
}

Even though I included in my sketchbook the USB HOST SHIELD 2.0 library and following step and renaming the library file to USB_Host_Shield_20 the error persists.

I do not believe that your error message matches the code.

The code should have been copied and pasted in code tags.
The error message should have been copied and pasted in code tags.

Please read three of the four locked topics at the top of this forum, and any links that they point to, etc.

In short…

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  5. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics by Nick Gammon near the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!