Use the hardware PwmOut to pulsate an LED (or something else), with selectable active high/low, customisable intensity function, gamma correction, and number of brightness levels.

Dependents:   RedButton

Revision:
10:1ade8e824939
Parent:
9:b40252f5fee7
--- a/Pulsator.h	Tue Apr 28 15:42:25 2015 +0000
+++ b/Pulsator.h	Mon May 18 13:28:03 2015 +0000
@@ -23,7 +23,7 @@
 #include <mbed.h>
 #include <PwmOut.h>
 
-class Pulsator : Ticker
+class Pulsator : private Ticker
 {
 private:
     PwmOut out;
@@ -34,7 +34,7 @@
     float (*_fun)(float phase);
     float _gamma;
     float _period;
-    int _levels;
+    uint16_t _levels;
 
     void disable(void);
     void enable(void);
@@ -49,6 +49,6 @@
     Pulsator& active_high(bool high = false);
     Pulsator& fun(float (*fp)(float phase) = NULL);
     Pulsator& gamma(float power = 2.2f);
-    Pulsator& levels(int number = 128);
+    Pulsator& levels(uint16_t number = 128);
     Pulsator& period(float seconds = 1.0f);
 };