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.

Revision:
0:8aa281e74b4a
Child:
1:1f6bd61833a3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LEDControl.cpp	Thu Jul 09 13:07:50 2015 +0000
@@ -0,0 +1,35 @@
+#include "LEDControl.h"
+#include "mbed.h"
+
+LEDControl::LEDControl(PinName pin, Timer *time):
+    _led(pin),
+    _nextBlink( 0 ),
+    _Time ( time )
+{
+    _led = 0;
+}
+
+void LEDControl::blink(float rate) {
+   long _currentTime = _Time->read_ms();
+   if(_currentTime - _nextBlink > 0)
+   {
+        if(_currentTime > 20000000)
+        {
+            _Time->reset();
+            _currentTime = 0;
+        }
+        _led = !_led; 
+        _nextBlink = 1000/rate + _currentTime;
+   }  
+}
+void LEDControl::off() {
+   _led = 0;
+}
+
+void LEDControl::on() {
+   _led = 1;
+}
+
+void LEDControl::toggle() {
+   _led = !_led;
+}
\ No newline at end of file