![](/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
Diff: main.cpp
- Revision:
- 0:941cccd337df
--- /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; + } +}