Oleg's barcode connect to arduino

Hi. Currently i’m on my last semester and have to finish a project which is called smart trolley. And i discovered oleg’s website which i already try but have some error. I did some slightly adjustment because i used 20x4 lcd. I have already fix the error i found on oleg’s, 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 this:

ec03d7607c880ee26711d541bc5cb534a2549a47.jpg

try to scan other barcode but it doesn’t show that specific barcode number. it just some random symbols.

#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();
}

can someone explain this

what do you see in the Serial Console?

J-M-L:
what do you see in the Serial Console?

it showed “Start” first. then i try to scan it with the same barcode, it shows like this

jkjk.PNG

and your barcode is [color=purple]8887549053696[/color] ? that’s exactly what the list of code shows → ASCII for your digits

the last 19 would be then DC3 in ASCII can represent XOFF so end of transmission, the device is stopping

I Suggest you modify the line lcd.print(key ); into lcd.print((char) key); to get an ASCII output on your LCD

You would need to filter out the DC3 code though, no need to send that to the LCD

J-M-L:
and your barcode is [color=purple]8887549053696[/color] ? that’s exactly what the list of code shows → ASCII for your digits

the last 19 would be then DC3 in ASCII can represent XOFF so end of transmission, the device is stopping

I Suggest you modify the line

lcd.print(key );

into

lcd.print((char) key);

to get an ASCII output on your LCD

You would need to filter out the DC3 code though, no need to send that to the LCD

its flickering:

P_20180926_110218.jpg

vcm.PNG

Can you make sure a simple “hello word” printing in the LCD does work ?

J-M-L: Can you make sure a simple “hello word” printing in the LCD does work ?

its does work... thats the first thing i do before 'copying' oleg's

Change the 200ms time out for erasing the LCD screen to something higher just to see what happens