Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
rgbled.h
00001 //Class to control an RGB LED using three PWM pins 00002 class RGBLed 00003 { 00004 public: 00005 RGBLed(PinName redpin, PinName greenpin, PinName bluepin); 00006 void write(float red,float green, float blue); 00007 private: 00008 PwmOut _redpin; 00009 PwmOut _greenpin; 00010 PwmOut _bluepin; 00011 }; 00012 00013 RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) 00014 : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) 00015 { 00016 //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) 00017 _redpin.period(0.0005); 00018 } 00019 00020 void RGBLed::write(float red, float green, float blue) 00021 { 00022 _redpin = red; 00023 _greenpin = green; 00024 _bluepin = blue; 00025 }
Generated on Fri Aug 12 2022 03:25:54 by
1.7.2