A barcode is a square or rectangular image consisting of a series of parallel black lines and white spaces of varying widths that can be read by a scanner. Barcodes are applied to products as a means of quick identification. They are used in retail stores as part of the purchase process, in warehouses to track inventory, and on invoices to assist in accounting, among many other uses.

In this tutorial we will make a simple Barcode Scanner that will display the barcode, product name and price in 3.5” TFT LCD display.

Here’s a sample video:

Hardware Components

You can buy it all here at CreateLabz.

Software Components

Application Discussion

Barcode Scanner

Is an electronic device that can read and output printed barcodes to a computer. Like a flatbed scanner, it consists of a light source, a lens and a light sensor translating for optical impulses into electrical signals.Additionally, nearly all barcode readers contain decoder circuitry analyzing the bar code’s image data provided by the sensor and sending the barcode’s content to the scanner’s output port.

How does it work:

A barcode scanner “scans” the black and white elements of a barcode by illuminating the code with a red light, which is then converted into matching text. More specifically, the sensor in the barcode scanner detects the reflected light from the illumination system (the red light) and generates an analog signal that is sent to the decoder. The decoder interprets that signal, validates the barcode using the check digit, and converts it into text.

USB Host Shield

USB Host Shield allows you to connect a USB device to your Arduino board. The Arduino USB Host Shield is based on the MAX3421E, which is a USB peripheral/host controller containing the digital logic and analog circuitry necessary to implement a full-speed USB peripheral or a full-/low-speed host compliant to USB specification rev 2.0. The shield is TinkerKit compatible, which means you can quickly create projects by plugging TinkerKit modules onto the board.

3.5” TFT LCD Shield

TFT LCD Shield contains a 16 bit color TFT screen with a large 3.5″ display and is designed to fit directly into the standard headers of an Arduino requiring no additional interface hardware. It support a relatively high resolution of 480 x 320 pixels.

Hardware Setup

1st Step: Mount the USB Host Shield on the Arduino Mega.

2nd Step: Connect the Barcode scanner to the USB Host Shield.

3rd Step: Mount the 3.5” TFT LCD Shield on the USB Host Shield.


Libraries Included

Arduino Code

Code Breakdown

This is the code where the barcode scanner will read the values stored in the barcode, and store it in an array. Then adds all the value and store it in the reg variable. And print it in serial monitor as a character.

In this code we begin the serial communication and initialize the TFT screen and display the “Barcode Scanner” text and the design elements.

In this code, we identify if the scanning of the barcode is complete. And displays the sum of all the values in a barcode and if the sum of the all the values in the barcode is equal to a registered value, then it will displays the product name, price and barcode in the TFT LCD. And then calls the OnScanFinished() function.

In this code if the function is called it will just reset the value of the reg variable or set it back to zero and also the scancounter variable.

Important Note!

Standard-sized Arduino boards, such as Duemilanove and UNO have SPI signals routed to pins 11-13 in addition to ICSP connector, therefore shields using pins 11-13 combined with standard-sized Arduinos will interfere with SPI. And since we are using 3.5” TFT LCD Shield that uses 11-13 pins for SPI communication. So it would be better if we use an arduino board that doesn’t use the pins 11 -13 for SPI communication, like the arduino mega.


Barcodes eliminate the possibility of human. A barcode scan is fast and reliable, and takes less time than entering data by hand. So this tutorial can be a good help in doing business much more efficient, and you can also modify or upgrade it.





Tags : 3.5'' TFT LCD Shieldarduinoarduino megabarcodeBarcode ReaderBarcode ScannerH1800 CCD Sensor 1D Scan Enginelcdmega2560TFT Shieldusb hostUSB Host Shield

Leave a Response