Barcode Scanner DE2120 - Arduino Mega scanner.begin() returns false

The DE2120 does work on an Arduino Uno, following your Hookup Guide. I am using the examples from the library.

But when I hook it up to a Arduino Mega 2560, the line

if (scanner.begin(softSerial) == false)

retruns false, making the code to Freeze, as intended.

But if I take out the while(1); ignoring the return value, the board works!

It seems that the Mega does act differently on the mentioned code line.

For now, I’m ok, it works… but it might be something for you to look at to improve the library?

Regards,

Nico```

ADDITIONAL MESSAGE

For some reason SoftSerial did not work (in post above I wrongly thought it did).

But I found a solution that works for me on the Mega. Use the extra Hardware ports on the Mega.

Made one change in the code to make it work for extra Mega Hardware serial port 2, referenced via Serial2

if (scanner.begin(**Serial2**) == false)

Maybe it’s an idea to add that option to your tutorial for users that use architecture with extra hardware serial ports.

And I’m curious why the Software version does not work on (my) Mega.

Regards

if (scanner.begin(Serial2) == false)

(without the , tried to make it bold… :smiley: )