You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A more complicated example: working with serial port IO. Let's say I have the following function:
72
+
73
+
```C++
74
+
void smartLightswitchSerialHandler(int pin) {
75
+
if (Serial.available() > 0) {
76
+
int incomingByte = Serial.read();
77
+
int val = incomingByte == '0' ? LOW : HIGH;
78
+
Serial.print("Ack ");
79
+
digitalWrite(pin, val);
80
+
Serial.print(String(pin));
81
+
Serial.print(" ");
82
+
Serial.print((char)incomingByte);
83
+
}
84
+
}
85
+
```
86
+
87
+
This function has 3 side effects: it drains the serial port's receive buffer, affects a pin, and puts data in the serial port's send buffer. Or, if the receive buffer is empty, it does nothing at all.
0 commit comments