A simple class for driving an RGB LED that uses standard color specification.

Dependencies:   C12832

Committer:
jensva
Date:
Fri Feb 05 13:55:49 2021 +0000
Revision:
1:f2ac6d53f63d
Parent:
0:396b3f9574ea
Potentiometer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vandep01 0:396b3f9574ea 1 #ifndef RGBLED_H
vandep01 0:396b3f9574ea 2 #define RGBLED_H
vandep01 0:396b3f9574ea 3
vandep01 0:396b3f9574ea 4 #include "PinNames.h"
vandep01 0:396b3f9574ea 5 #include "mbed.h"
vandep01 0:396b3f9574ea 6
vandep01 0:396b3f9574ea 7 /** \brief A wrapper for an RGB LED connected to a PWM. This class simplifies the
vandep01 0:396b3f9574ea 8 * setting of the color and also provides some basic color definitions.
vandep01 0:396b3f9574ea 9 */
vandep01 0:396b3f9574ea 10 class RGBLed
vandep01 0:396b3f9574ea 11 {
vandep01 0:396b3f9574ea 12 public:
vandep01 0:396b3f9574ea 13 RGBLed(PinName redPin, PinName greenPin, PinName bluePin);
vandep01 0:396b3f9574ea 14
vandep01 0:396b3f9574ea 15 /** \Brief Initialize the LED */
vandep01 0:396b3f9574ea 16 void init();
vandep01 0:396b3f9574ea 17
vandep01 0:396b3f9574ea 18 /** \Brief Set the color of the RGB LED */
vandep01 0:396b3f9574ea 19 void setColor(const float red, const float green, const float blue);
vandep01 0:396b3f9574ea 20
vandep01 0:396b3f9574ea 21 private:
vandep01 0:396b3f9574ea 22 PwmOut m_red;
vandep01 0:396b3f9574ea 23 PwmOut m_green;
vandep01 0:396b3f9574ea 24 PwmOut m_blue;
vandep01 0:396b3f9574ea 25 };
vandep01 0:396b3f9574ea 26
vandep01 0:396b3f9574ea 27 #endif