Hi,
I have tested the sample code given in the hookup guide. The hardware serial port doesn’t echo back the characters sent to it by the SerialUSB port.
Here’s the example code that I run:
void setup()
{
SerialUSB.begin(9600); // Initialize Serial Monitor USB
Serial.begin(9600); // Initialize hardware serial port, pins 17/16
while (!SerialUSB) ; // Wait for Serial monitor to open
// Send a welcome message to the serial monitor:
SerialUSB.println(“Send character(s) to relay it over Serial”);
}
void loop()
{
if (SerialUSB.available()) // If data is sent to the monitor
{
String toSend = “”; // Create a new string
while (SerialUSB.available()) // While data is available
{
// Read from SerialUSB and add to the string:
toSend += (char)SerialUSB.read();
}
// Print a message stating what we’re sending:
SerialUSB.println(“Sending " + toSend + " to Serial”);
// Send the assembled string out over the hardware
// Serial port (TX pin 1).
Serial.print(toSend);
}
if (Serial.available()) // If data is sent from device
{
String toSend = “”; // Create a new string
while (Serial.available()) // While data is available
{
// Read from hardware port and add to the string:
toSend += (char)Serial.read();
}
// Print a message stating what we’ve received:
SerialUSB.println(“Received " + toSend + " from Serial”);
}
}
PFA the screenshot of the serial monitor.
Please guide.
Regards