Tips & Managements
[아두이노] 시리얼 객체를 함수 arg로 넘기는 방법
푸른샛별
2022. 1. 3. 17:37
시리얼 객체, 특히 메가 시리즈 등 다수의 시리얼을 가진 아두이노 개발 보드를 다룰 때, 특정 함수를 다양한 시리얼 객체에 적용하고자 할 경우에 타입으로 Stream &을 사용하면 arg로 쉽게 넘길 수 있다.
void test_function(Stream &stream) {
....
}
void loop(){
test_function(Serial);
test_function(Serial1);
test_function(Serial2);
test_function(Serial3);
}