Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This code demonstrates how to use the EP3000 Barcode/QR Scanner to read barcode data and output it to the serial monitor. The SoftwareSerial library is used to create a software serial port for the scanner communication.
- To use this code, connect the EP3000 Barcode/QR Scanner to your Arduino board according to the wiring diagram provided in the product documentation. The scanner should be powered with a suitable power source (usually 5V DC). The code initializes the scanner serial communication using the begin() function of the SoftwareSerial library, and waits for the scanner to initialize using the delay() function. It then enables manual trigger mode using the $emg command sent to the scanner via the write() function of the SoftwareSerial library. The loop() function reads the barcode data from the scanner using the readString() function of the SoftwareSerial library when it is available, and prints it to the serial monitor using the println() function of the Serial library.
- Note that the EP3000 Barcode/QR Scanner supports various communication modes and barcode types. You may need to modify the code to match the specific mode and barcode type you are using. Also, the scanner may require some configuration and calibration before it can function properly. Please refer to the product documentation for more information.
- */
- #include <SoftwareSerial.h>
- SoftwareSerial scanner(2, 3); // RX, TX
- void setup() {
- Serial.begin(9600); // Initialize the serial communication
- scanner.begin(115200); // Initialize the scanner serial communication
- delay(1000); // Wait for the scanner to initialize
- scanner.write("$emg\r\n"); // Enable manual trigger mode
- delay(1000); // Wait for the scanner to enter manual trigger mode
- }
- void loop() {
- if (scanner.available()) {
- String barcode = scanner.readString(); // Read the barcode data from the scanner
- Serial.println(barcode); // Print the barcode data to the serial monitor
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement