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.
Revision 1:38f70a2c8f31, committed 2016-05-12
- Comitter:
- qynx
- Date:
- Thu May 12 04:46:59 2016 +0000
- Parent:
- 0:f333a5217736
- Commit message:
- text change
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jun 27 22:40:54 2014 +0000
+++ b/main.cpp Thu May 12 04:46:59 2016 +0000
@@ -1,37 +1,40 @@
#include "mbed.h"
-
PwmOut r (LED1);
PwmOut g (LED2);
PwmOut b (LED3);
- float RGB_Colour[3];
+float RGB_Colour[3];
- int main() {
+int main()
+{
r.period(0.001);
-
+
+
while(1) {
+
RGB_Colour[0] = 1.0; // start with red
RGB_Colour[1] = 0.0;
- RGB_Colour[2] = 0.0;
+ RGB_Colour[2] = 0.0;
+
+ for (int DEC_Colour = 0; DEC_Colour < 3; DEC_Colour += 1) {
+ int INC_Colour = DEC_Colour == 2 ? 0 : DEC_Colour + 1;
+
+ // cross-fade the two colors.
+ for(float i = 0.0; i < 1.0 ; i += 0.001) {
+ RGB_Colour[DEC_Colour] -= 0.001;
+ RGB_Colour[INC_Colour] += 0.001;
- for (int DEC_Colour = 0; DEC_Colour < 3; DEC_Colour += 1) {
- int INC_Colour = DEC_Colour == 2 ? 0 : DEC_Colour + 1;
-
- // cross-fade the two colours.
- for(float i = 0.0; i < 1.0 ; i += 0.001) {
- RGB_Colour[DEC_Colour] -= 0.001;
- RGB_Colour[INC_Colour] += 0.001;
-
- r = 1.0-RGB_Colour[0];
- g = 1.0-RGB_Colour[1];
- b = 1.0-RGB_Colour[2];
-
- wait(0.001);
+ r = 1.0-RGB_Colour[0];
+ g = 1.0-RGB_Colour[1];
+ b = 1.0-RGB_Colour[2];
+
+ wait(0.001);
+ }
+ }
}
- }
- }
+
}