Simple library for controlling LEDs. Turn them on & off, blink them at specified rates and toggle their output. Don't forget to add a timer for the LEDs to use. Documentation found in header file.
Diff: LEDControl.h
- Revision:
- 0:8aa281e74b4a
- Child:
- 1:1f6bd61833a3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LEDControl.h Thu Jul 09 13:07:50 2015 +0000 @@ -0,0 +1,34 @@ + +#include "mbed.h" + +/** Simple class for controlling LEDs + * + * Author: Andrew Edwards + * + * Example of use: + * @code + * #include "mbed.h" + * #include "LEDControl.h" + * + * int main() { + * LEDControl Blue(PC_10); + * Blue.on(); (default blink rate is 10 Hertz) + * wait(2); + * Blue.on(100); // Blink at 100Hz + * Blue.off(); // LED OFF + * Blue.alwayson(); // LED Stays on until off is called + * } + */ +class LEDControl { +private: + Timer *_Time; + DigitalOut _led; + float _nextBlink; +public: + LEDControl(PinName pin, Timer *time); + //void blink(int n, float t = 0.2); + void blink(float rate = 5); + void off(); + void on(); + void toggle(); +};