Arduino_Fade sample code ported.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
homayoun
Date:
Wed Sep 03 12:33:33 2014 +0000
Commit message:
Arduino_Fade

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a594269e86ab main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 03 12:33:33 2014 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+PwmOut led(LED1);
+
+float brightness = 0.0f;    // how bright the LED is
+float fadeAmount = 0.02f;    // how many points to fade the LED by
+
+// the setup routine runs once when you press reset:
+void setup()
+{
+
+}
+
+void loop()
+{
+    brightness += fadeAmount;
+    if (brightness <= 0.0f || brightness >= 1.0f) fadeAmount = -fadeAmount; // == doesn't work!!!
+    led = brightness;
+    wait(0.03);
+}
+
+int main()
+{
+    setup();
+    while(1) loop();
+}
\ No newline at end of file
diff -r 000000000000 -r a594269e86ab mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 03 12:33:33 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file