How to Interface Barcode Scanner Module with Arduino

To test any barcode scanner you can connect the scanner to USB port of PC & Open NOTEPAD or Microsoft WORD.
Scan any barcode to see the code printed on notepad window.
As you connect BARCODE SCANNER to PC it is considered as HID device (like mouse or keyboard) and any result from device will be printed on Notepad.
For connecting the scanner with Arduino you need an USB HOST Module.
CONNECTIONS BETWEEN SCANNER MODULE WITH ARDUINO:-
RXD of host connected to Tx of Arduino
TXD of host connected to Rx of Arduino
Power to scanner taken from Arduino 5v pin
Gnd to Gnd
HOW TO UPLOAD PROGRAM:-
While uploading code , remove connections at Rx/Tx pins.After upload successful connect back the pins.
CODE:-
int count = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available())
{
count = 0;
while(Serial.available())
{
char input = Serial.read();
Serial.print(input);
count++;
delay(5);
}
Serial.println();
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.