2036 project
Dependencies: 4DGL-uLCD-SE EthernetInterface NTPClient SDFileSystem mbed-rtos mbed wave_player
Fork of 2036lab7_template by
RGB.h
- Committer:
- baaosen
- Date:
- 2018-10-25
- Revision:
- 1:a5f43fb83aca
File content as of revision 1:a5f43fb83aca:
#include "mbed.h" //Class to control an RGB LED using three PWM pins class RGBLed { public: RGBLed(PinName redpin, PinName greenpin, PinName bluepin); void write(float red,float green, float blue); private: PwmOut _redpin; PwmOut _greenpin; PwmOut _bluepin; }; RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) { //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) _redpin.period(0.0005); } void RGBLed::write(float red,float green, float blue) { _redpin = red; _greenpin = green; _bluepin = blue; } //class could be moved to include file //Setup RGB led using PWM pins and class