MH ET live Scanner beeps which indicates it has read the barcode but not displaying on screen.
Here are my connections
scanner - arduino
s-rx - pin 3
s-tx - pin 2
vcc - 5v
gnd - gnd
button - pin 8
i am using arduino uno also used arduino mega but still wont get any thing on my serial monitor , i have tried all the possible things availble on different forums, youtube videos but wont get the solution below is my daigram and code,
String inputString = ""; // Variable to store the scanner input
String DataScanner = ""; // Variable for processing the scanner data
bool stringComplete = false; // Variable to check if the data is completely received
void setup() {
pinMode(8, OUTPUT); // Pin for triggering the scanner
Serial.begin(9600); // Initialize the main serial communication for debugging
Serial1.begin(9600); // Initialize Serial1 for communication with the scanner
// Reserve 200 characters for the inputString
inputString.reserve(200);
Serial.println("Setup complete, starting loop...");
}
void loop() {
digitalWrite(8, HIGH); // Send a logic HIGH signal
delay(200); // Wait for 200 milliseconds
digitalWrite(8, LOW); // Send a logic LOW signal, simulating a button press to trigger the scanner
delay(200); // Wait for 200 milliseconds
// Check if the data from the scanner is completely received
if (stringComplete) {
Serial.print("Received Data: ");
Serial.println(DataScanner); // Print the received data for debugging
if (DataScanner == "8859411300023\r\n") { // If the data matches the specified value, print "OK"
Serial.println("OK");
delay(1000);
} else {
Serial.println("No Data"); // If the data doesn't match, print "No Data"
}
// Clear the variables for new data
inputString = "";
DataScanner = "";
stringComplete = false;
}
}
/*
SerialEvent1 occurs whenever new data comes in the hardware serial RX1. 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 serialEvent1() {
while (Serial1.available()) {
// Get the new byte:
char inChar = (char)Serial1.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;
DataScanner = String(inputString);
}
}
}