I am using the attached sketch to control several string of LED lights with an Arduino Mega 2560. The Arduino is connected to a Windows 7 PC via USB. There is also a barcode scanner connected to the PC via USB. The idea is that a barcode is scanned and the corresponding LED lights up. The sketch works just fine but only if the Serial Monitor is running and in focus. If the Serial Monitor is minimized or not running then the sketch does not work. Is this normal or is there something I am missing? I would like to be able to transmit directly from the barcode scanner to the Arduino to the LEDs. Code is attched (Too long to put inline).Thank you.
You probably have some software installed on your machine that is antisocially
probing all the serial ports cyclicly, so that whenever the Arduino port isn't
exclusively owned by the serial monitor it gets probed (thus resetting the Arduino).
Or that's the impression I get from many previous posts about such troubles on Windows.
it's because your usb scanner is a keyboard wedge type. It sends it signal as if it is coming from the keyboard. If you can get it, you want a serial barcode scanner, and have it hooked up the serial ports directly on the mega.