Can I have Serial and Serial1 working at the same time?
void setup() {
Serial.begin(9600);
while (!Serial); // while not open, do nothing
Serial1.begin(9600);
}
void loop() {
while (Serial.available() > 0) { // if at least one char is available
/* CODE */
//Serial.write(Serial.read());
}
while (Serial1.available() > 0) {
/* CODE */
//Serial.write(Serial1.read());
}
}
When I open the Serial Monitor the first while works good but if I have both, the second one is printing results in a endless loop. How can I solve this?
»» The Arduino Leonardo board uses Serial1 to communicate via RS232 on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication.
Can I use Serial1
exactly like Serial
? What kind of signals are read on Serial1?
while (!Serial1);
– thejhSerial.write
, too? NotSerial1.write
? – thejh