![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fades the LEDs on the mbed so they look like the front of the Knightrider car :P
Revision 0:941cccd337df, committed 2010-03-14
- Comitter:
- jphastings
- Date:
- Sun Mar 14 16:54:12 2010 +0000
- Commit message:
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 941cccd337df main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 14 16:54:12 2010 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" + +PwmOut led1(LED1); +PwmOut led2(LED2); +PwmOut led3(LED3); +PwmOut led4(LED4); + +int position = 1; +int direction = 1; +int max = 50; + +int main() { + while(1) { + led1 = led1 - 0.05; + led2 = led2 - 0.05; + led3 = led3 - 0.05; + led4 = led4 - 0.05; + + if (position < (4 * max / 15)) { + } else if (position < (6 * max / 15)) { + led1 = 1; + } else if (position < (8 * max / 15)) { + led2 = 1; + } else if (position < (10 * max / 15)) { + led3 = 1; + } else if (position < (12 * max / 15)) { + led4 = 1; + } + + wait(1/max); + + if (position == max || position == 0) { + direction *= -1; + } + + position += direction; + } +}
diff -r 000000000000 -r 941cccd337df mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 14 16:54:12 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0