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.
LEDController.cpp
00001 #include "globals.h" 00002 #include "hardware.h" 00003 #include "LEDController.h" 00004 00005 00006 RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) 00007 : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) 00008 { 00009 //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) 00010 _redpin.period(0.0005); 00011 } 00012 00013 void RGBLed::write(float red,float green, float blue) 00014 { 00015 _redpin = red; 00016 _greenpin = green; 00017 _bluepin = blue; 00018 } 00019 //class could be moved to include file 00020 00021 00022 //Setup RGB led using PWM pins and class 00023 RGBLed myRGBled(p23,p22,p21); //RGB PWM pins 00024 00025 void Control() { 00026 myRGBled.write(1.0,0.0,0.0); //red 00027 } 00028 00029 void NoControl() { 00030 myRGBled.write(0.0,0.0,0.0); //red 00031 }
Generated on Thu Sep 1 2022 20:44:59 by
1.7.2