display barcode number to LCD

i have already fix the error i found on oleg's connect to barcode scanner to arduino. but does the coding display barcode number to lcd? because i can't display it when i try to scan for example like "8887549053696" and the lcd came out like in the attachment. try to scan other barcode but it doesn't show the barcode number. it just some random symbols.

this is oleg's connect barcode scanner to arduino coding. i only did a slight adjustment.

#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
//#include <address.h>
//#include <avrpins.h>
//#include <max3421e.h>
//#include <usbhost.h>
//#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>

#include <hidboot.h>

//#include <printhex.h>
//#include <message.h>
//#include <hexdump.h>
//#include <parsetools.h>

#define DISPLAY_WIDTH 20

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

USB Usb;
//USBHub Hub(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);

class KbdRptParser : public KeyboardReportParser
{

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.println(key );
lcd.print(key );
};

KbdRptParser Prs;

void setup()
{
Serial.begin( 9600 );
Serial.println("Start");

if (Usb.Init() == -1) {
Serial.println("OSC did not start.");
}

delay( 200 );

Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
// set up the LCD's number of columns and rows:
lcd.begin(DISPLAY_WIDTH, 4);
lcd.clear();
lcd.noAutoscroll();
lcd.print("Ready");
delay( 200 );
}

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

Maybe this can help.

OK, let's cut to the chase.

Please go and read the instructions, then go back and modify your post using the "More --> Modify" option you will find to the bottom right of the post, to mark up the code (but it always needs to be the complete code) as such so we can examine it conveniently and accurately. Please do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

If you do not mark it up as code, whatever code you do post could well be garbled and is certainly anything but easy to read. Yours seems to have survived so far but I didn't look too closely.

Note: Also mark up any data - as a separate section - in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.

Your image:

Use </>, on left side toolbars fiture to put your code.

#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
//#include <address.h>
//#include <avrpins.h>
//#include <max3421e.h>
//#include <usbhost.h>
//#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>

#include <hidboot.h>
 
//#include <printhex.h>
//#include <message.h>
//#include <hexdump.h>
//#include <parsetools.h>
 
#define DISPLAY_WIDTH 20
 
// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
USB     Usb;
//USBHub     Hub(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    Keyboard(&Usb);
 
class KbdRptParser : public KeyboardReportParser
{
 
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.println(key );
    lcd.print(key );
};
 
KbdRptParser Prs;
 
void setup()
{
    Serial.begin( 9600 );
    Serial.println("Start");
 
    if (Usb.Init() == -1) {
        Serial.println("OSC did not start.");
    }
 
    delay( 200 );
 
    Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
    // set up the LCD's number of columns and rows:
    lcd.begin(DISPLAY_WIDTH, 4);
    lcd.clear();
    lcd.noAutoscroll();
    lcd.print("Ready");
    delay( 200 );
}
 
void loop()
{
  Usb.Task();
}