I just started studying electronics and how to program an arduino, please consider helping me find a solution.
Hello, I am working on a project that involves the use of a barcode scanner. I am having problems with my module. I am using MH-ET LIVE Scanner v3.0 and when I tested the product via HID connection to see if it works. it works fine when I first got the product. Then I tried to follow instructions on youtube on how to connect it to an arduino. This is what ive watched: https://youtu.be/xX_GDkPJ6x0 he built it using the code from this site
I thought that I could make this work without the need for the additional usb connection connected to the scanner just like the youtube video. I just want the USB serial connection to the arduino alone, then just pins to power up the scanner. This is the ideal result
Unfortunately, I am not able to upload my code to my arduino, here is the error message
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc2
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xc2
I don't know if this is a software or a hardware issue
Tried unplugging and replugging, restarting pc, restoring barcode module to factory settings, and nothing works. My connections are fine, my arduino is working well with other devices. I can upload other code to my other sensors.
Now when I tried to check it if it still works on HID connection, it is now not working properly. Scanner beeps which indicates it has read the barcode but not displaying on screen. It did this when I restored the scanner to factory settings. I think the scanner is still working because it can still scan the qr code on the manual when i try to configure it by scanning qr settings. But it no longer puts the text barcode on my computer even though my computer can detect it as an HID keyboard device. I tried following this guide but it didnt work.. [open config mode,scan code in manual]
Here is the code I am trying to test based on the video
// Variable for storing values from the scanner
String inputString = "";
// Variable for storing values in processing
String DataScanner = "";
// Variable to check if data is complete or not
bool stringComplete = false;
void setup() {
// Pin for triggering the scanner to work
pinMode(8, OUTPUT);
// Initialize serial communication
Serial.begin(9600);
// Wait for serial port to connect. Needed for native USB port only
while (!Serial) {
;
}
// Declare a variable for storing a message with a size of 200 characters
inputString.reserve(200);
}
void loop() {
// Send a digital high signal to the pin
digitalWrite(8, HIGH);
// Delay for 1 second
delay(1000);
// Send a digital low signal to the pin to trigger the scanner
digitalWrite(8, LOW);
// Delay for 1 second
delay(1000);
// Check if data from the scanner is complete
if (stringComplete) {
// If the data matches what is set, display "OK"
if (DataScanner == "8859411300023\r\n") {
Serial.println("OK");
delay(1000);
}
// If the data does not match what is set, display "No Data"
else {
Serial.println("No Data");
}
// Clear the variables to wait for new data
inputString = "";
DataScanner = "";
stringComplete = false;
}
}
/*
SerialEvent occurs whenever a new data comes in the hardware serial RX. This
routine is run between each time loop() runs, so using delay inside loop can
delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// Get the new byte
char inChar = (char)Serial.read();
// Add it to the inputString
inputString += inChar;
// If the incoming character is a newline, set a flag so the main loop can
// do something about it
if (inChar == '\n') {
stringComplete = true;
// Convert inputString to a string and store in DataScanner
DataScanner = String(inputString);
}
}
}
Here are my connections
scanner - arduino
s-rx - pin 3
s-tx - pin 2
vcc - 5v
gnd - gnd
button - pin 8
Additional note: when i connect the vcc and gnd, my barcode module doesn't turn on, only when i try to connect pin 8 does it lights up, but it still doesnt fully power on the scanner, just the barcode flash blinking. the red light doesnt even turn on
Please help me, I need this project for school. And i've been trying to fix this issue for a month now. Thanks a lot!