Our logo is displayed while the scanner waits for input. We created three images, two for the games and another using our logo. We had to manually edit the image to match the screen resolution exactly, if there is even a pixel difference, the code will error.
We added an extra few lines to show a screenshot of the game on the 280 x 135 resolution screen. If there was a match, the name of the game is printed to the Python Shell. A conditional test would check the data read by the barcode scanner and compare it against the two known barcodes. We used the barcode from two games as our test. Data is output as bytes, essentially a string of text starting with b followed by the barcode data contained in ‘’, the final character /r is a carriage return.Īfter grabbing a bunch of PlayStation 1 games from our attic, we set to creating a demo to learn more about the Barcode Reader HAT.
#Raspberry pi qr code reader serial
We chose to use the scanner as a serial device and after working through the example applications we got a grasp of how it worked. Using a special barcode to configure the reader as a USB keyboard, we connected the HAT to our Windows 10 PC and started scanning random barcodes, all of which appeared in our text editor window. We did test the Barcode Scanner HAT away from the Raspberry Pi.
The scanner can be reprogrammed to act as a keyboard, outputting data as if it were a keyboard via the micro USB port which means it can be used with another computer. The base of the Python library is all about interacting with the DE2120 scanner module which can spit out data via a serial / UART connection.