Writing and using the Blinker class
In the previous chapter, we learned how to write code that can independently blink an LED and print a message using the cooperative multitasking framework. In this section, we will create the object-oriented version of this code, but only for the blinking part, to keep things a little more concise. At first sight, the object-oriented version might not look like a better way of doing it since it requires even more code. However, if you think about how to scale this code up to blinking many LEDs at different frequencies, the object-oriented code will clearly become the better choice. For reference, the following is the blink part of the state machine example from the last chapter:
unsigned long last_blink_time; int blink_interval = 200; void setup() { Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); last_blink_time = millis(); } void loop() { if (millis() - last_blink_time >= blink_interval)...