Demo of LED lighting effects using PWM and wait for time delays. Pins are setup for LPC1768 platform’s LEDs. For complete information, see http://developer.mbed.org/users/4180_1/notebook/led-lighting-effects-for-modelers/

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
4180_1
Date:
Fri Nov 28 17:58:01 2014 +0000
Commit message:
ver 1.0

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 689e5e7eafb1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 28 17:58:01 2014 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+//LED House Lighting effect with flickering TV and room lights randomly changing
+DigitalOut porch(LED1);
+DigitalOut room(LED2);
+DigitalOut room2(LED3);
+//DigitalOut OK for LEDs just turing on and off
+PwmOut TV(LED4);
+//Need PWM for nice flickering TV effect
+
+//Use Cs random number generator rand(), but scaled and
+//converted to a float from 0.0 to 1.0
+inline float random_number()
+{
+    return (rand()/(float(RAND_MAX)));
+}
+
+int main()
+{
+    float x=0.0;
+    porch = 1;
+    while(1) {
+        x = random_number();
+        TV = x;
+        if (x >0.98) room = !room;
+        if (x >0.99) room2 = !room2;
+        wait(0.05);
+    }
+}
diff -r 000000000000 -r 689e5e7eafb1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 28 17:58:01 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file