Basic RGB library for non-PWM LEDs

Dependents:   MenuExample exosite_http_example exosite_http_example FastPWM

Warning : Works with non-PWM LED (0 or 1).

A quick example on how to use it.

#include "mbed.h"
#include "RGBLed.h"

RGBLed led(LED_RED, LED_GREEN, LED_BLUE);

int main() {
    RGBLed::Color list[8] = {RGBLed::BLACK, RGBLed::RED, RGBLed::GREEN, RGBLed::BLUE, RGBLed::MAGENTA, RGBLed::CYAN, RGBLed::YELLOW, RGBLed::WHITE};
    int i = 0;

    while (true) {
        i = (i+1)%8;
        led.setColor(list[i]);
        wait_ms(100);
    }
}

Files at this revision

API Documentation at this revision

Comitter:
rominos2
Date:
Wed Sep 03 19:32:25 2014 +0000
Parent:
4:176363412797
Child:
6:9b7ee7ba4109
Commit message:
Add #ifndef on headers

Changed in this revision

RGBLed.h Show annotated file Show diff for this revision Revisions of this file
--- a/RGBLed.h	Wed Sep 03 10:46:40 2014 +0000
+++ b/RGBLed.h	Wed Sep 03 19:32:25 2014 +0000
@@ -17,6 +17,9 @@
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#ifndef INCLUDE_RGBLED_H
+#define INCLUDE_RGBLED_H
+
 #include "mbed.h"
 
 /** A  light RGB LED Class \n
@@ -80,4 +83,6 @@
     static Color CYAN; /**< Cyan Color (Green + Blue) */
     static Color YELLOW; /**< Yellow Color (Red + Green) */
     static Color WHITE; /**< White Color (Red + Green + Blue) */
-};
\ No newline at end of file
+};
+
+#endif
\ No newline at end of file