Skip to content

Instantly share code, notes, and snippets.

@wilyJ80
Created January 24, 2026 12:55
Show Gist options
  • Select an option

  • Save wilyJ80/3828707a77dfd86941df05dd9f28df83 to your computer and use it in GitHub Desktop.

Select an option

Save wilyJ80/3828707a77dfd86941df05dd9f28df83 to your computer and use it in GitHub Desktop.
leds
class Led {
public:
Led(byte pinNo) : _pinNo(pinNo), _prev(0) {
pinMode(_pinNo, OUTPUT);
}
void update(unsigned const long interval);
private:
byte _pinNo;
unsigned long _prev;
};
void Led::update(unsigned const long interval) {
unsigned long cur = millis();
if (cur - _prev > interval) {
digitalWrite(Led::_pinNo, !digitalRead(Led::_pinNo));
_prev = cur;
}
}
void setup() {
}
void loop() {
static Led red(4);
red.update(50);
static Led yellow(16);
yellow.update(500);
static Led green(17);
green.update(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment