Glad it works. In case you are interested, here some remarks:
Code:
void activate()
{
pinMode(pin, OUTPUT);
if (digitalRead(pin) == LOW)
digitalToggle(pin);
}
I don't quite understand this logic. activate will always end up with pin HIGH.
So, why not simply do a
Code:
void activate()
{
pinMode(pin, OUTPUT);
digitalWriteFast(pin,HIGH);
}
Same for deactivate.
You can also place the pinMode into the constructor. Then you don't have to call it each and every time and it would make your LED class even smaller. (I know that people say that one shouldn't access hardware in the constructor but I never ran into problems with pinMode in a constructor).
Last but not least, you can also replace your include guards
Code:
#ifndef LED_h
#define LED_h
...
#endif
by a simple
on top of the file (but that's a matter of taste...)
EDIT: ---------------------------------
I'd also add a
Code:
void operator=(uint8_t state) const
{
digitalWriteFast(pin, state);
}
Then you can simply say
Code:
led = HIGH;
led = LOW;