Its a Pro Micro (ATmega32U4).
How do i need to change this that it also prints to Serial1 (UART):
#define print(...) Serial.print(__VA_ARGS__)
#define println(...) Serial.println(__VA_ARGS__)
void setup() {
Serial.begin(9600, SERIAL_7E2);
println();
println(F("Test"));
println();
}
This does not work:
#define print(...) Serial.print(__VA_ARGS__)
#define println(...) Serial.println(__VA_ARGS__)
#define print(...) Serial1.print(__VA_ARGS__)
#define println(...) Serial1.println(__VA_ARGS__)
void setup() {
Serial.begin(9600, SERIAL_7E2);
Serial1.begin(9600, SERIAL_7E2);
println();
println(F("Test"));
println();
}
Robin2
May 20, 2018, 10:56am
2
What's wrong with
Serial.println("my text");
Serial1.println("my text");
If you explain the purpose of what you are trying to do it will be easier to help.
...R
dev_1
May 20, 2018, 12:38pm
3
You could use my NeoTee class:
#include <NeoTee.h>
Print *outputs[] = { &Serial, &Serial1 };
NeoTee tee( outputs, 2 );
#define print(...) tee.print(__VA_ARGS__)
#define println(...) tee.println(__VA_ARGS__)
void setup()
{
Serial .begin(9600, SERIAL_7E2);
Serial1.begin(9600);
println();
println(F("Test"));
println();
}
void loop() {}
Robin2:
What's wrong with
Serial.println("my text");
Serial1.println("my text");
That you have to write everything twice...
@-dev, thanks that works.
Or just fix your macros to do it:
#define print(...) Serial.print(__VA_ARGS__); Serial1.print(__VA_ARGS__)
#define println(...) Serial.println(__VA_ARGS__); Serial1.println(__VA_ARGS__)
--- bill
you have to write everything twice...
Yes, but you could put the actual output code in a function and call it with the text or data to be printed as a parameter. One function call, two outputs.