/* PlainLed.cpp - Plain LED Class Implementation This class can be used with an LED connected to any of the digital I/O pins. They do not have to use the PWM outputs. */ #include "PlainLed.h" /* begin - Initialization void begin (byte pin) This method is generally run within "setup" to initialize the LED and associate it with the specified output pin. The "pinmode" method is then called to establish the pin as an OUTPUT. */ void PlainLed::begin (byte pin) { _pin = pin; pinMode(_pin, OUTPUT); } /* on - Turn the LED On void on () Turns the LED on using "digitalWrite". */ void PlainLed::on () { digitalWrite(_pin, HIGH); _isOn = true; } /* off - Turn the LED Off void off () Turns the LED off using "digitalWrite". */ void PlainLed::off () { digitalWrite(_pin, LOW); _isOn = false; } /* toggle - Change the State of the LED void toggle () If the LED is on, it is turned off. If the LED is off, it is turned on. */ void PlainLed::toggle () { if (_isOn) { off(); } else { on(); } } /* isOn - Test that LED is On bool isOn () Returns true if the LED is on. Otherwise, false is returned. */ bool PlainLed::isOn () { return _isOn; } /* isOff - Test that LED is Off bool isOff () Returns true if the LED is off. Otherwise, false is returned. */ bool PlainLed::isOff () { return ! _isOn; }