Connect Teensy 3.1 with scanner (USB keyboard)

Status
Not open for further replies.

lubosko

Member
Hi all.
I am new with Teensy and need help.
I need to connect USB barcode scanner to Teensy 3.1, read data, adjust the data and send via UART 1 to another device.
Teensy must be a host for scanner. I coppy and try to adjust some code:

#include <HardwareSerial.h>

Serial USB = Serial();
Serial2 Uart = Serial2();

void setup() {
USB.begin(9600);
Uart.begin(38400);
}

void loop() {
int incomingByte;

if (USB.available() > 0)
{
incomingByte = USB.read();
USB.print("USB received: ");
USB.println(incomingByte, DEC);
Uart.print("USB received:");
Uart.println(incomingByte, DEC);
}
}


why it doesn't recognize what is "Serial"?
 
Status
Not open for further replies.
Back
Top