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.
Diff: main.cpp
- Revision:
- 2:8d698a18ae6f
- Parent:
- 1:b2a97244857c
diff -r b2a97244857c -r 8d698a18ae6f main.cpp
--- a/main.cpp Sat May 31 19:07:57 2014 +0000
+++ b/main.cpp Mon Jun 09 17:53:46 2014 +0000
@@ -1,10 +1,8 @@
#include "mbed.h"
- DigitalOut red(D7);
-DigitalOut green(D6);
-DigitalOut blue(D5);
-
-
+PwmOut red(D7);
+PwmOut green(D6);
+PwmOut blue(D5);
int maincolor(void)
{
@@ -35,7 +33,7 @@
blue=0;
wait(1);
- red=0; //cyan... green and bue
+ red=0; //cyan... green and blue
green=1;
blue=1;
wait(1);
@@ -54,11 +52,28 @@
}
+int spectrum(void)
+{
+ red.period(0.001);
+ for(float i = 0.0; i < 1.0 ; i += 0.001)
+ {
+ float p = 3 * i;
+ red = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);
+ green = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);
+ blue = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0); ;
+ wait (0.01);
+ }
+ return 0;
+}
+
+
+
int main(void)
{
while(1)
{
maincolor();
+ spectrum();
}
}
\ No newline at end of file