- Thu Oct 18, 2018 11:38 am
#200701
I am attempting to port code from the Arduino mini over to the Pro Micro (5V 16MHz) and having trouble with serial communications.
Substituting serial1.print (for Arduino serial.print) works fine. However, serial input to the device does not.
Example:
void serialEvent()
{
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;
}
}
}
This function compiles OK, but does not work. inputString remains empty, and stringComplete remains false.
I know the serial port hardware is different with the ATMEG32U4 chip on the ProMicro so there might be something in SETUP() that I do not know to include (beyond Serial1.begin(9600);)
I have verified that the serial data is getting to the Rx pin in the proper format with the oscilloscope.
Any ideas?
Substituting serial1.print (for Arduino serial.print) works fine. However, serial input to the device does not.
Example:
void serialEvent()
{
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;
}
}
}
This function compiles OK, but does not work. inputString remains empty, and stringComplete remains false.
I know the serial port hardware is different with the ATMEG32U4 chip on the ProMicro so there might be something in SETUP() that I do not know to include (beyond Serial1.begin(9600);)
I have verified that the serial data is getting to the Rx pin in the proper format with the oscilloscope.
Any ideas?