Same Function for different Serialports


i'm on a Arduino Mega 2560 and want to use the four independent serial ports.

So is it possible, to use the same functions for each and pass over the serial port, which should be used?

Something like process_data(serial_2)?

thank you for your help.


Yes. The Serial objects are of type Stream. Make your function take a pointer to a Stream object.