Adam Kraczkowski
/
PWMBlinking_LED_example
PWM Blinking LED example
main.cpp
- Committer:
- zuko
- Date:
- 2012-06-10
- Revision:
- 0:ef666343e506
File content as of revision 0:ef666343e506:
#include "mbed.h" PwmOut led1(LED1); PwmOut led2(LED2); PwmOut led3(LED3); PwmOut led4(LED4); int main() { int a = -1; float max = 1; float medium = 0.2; float low = 0.01; while(1) { a += 1; if (a == 12) { a = 0; } wait(0.5); switch(a){ case 0: led1 = max; led2 = 0; led3 = 0; led4 = 0; break; case 1: led1 = medium; led2 = max; led3 = 0; led4 = 0; break; case 2: led1 = low; led2 = medium; led3 = max; led4 = 0; break; case 3: led1 = 0; led2 = low; led3 = medium; led4 = max; break; case 4: led1 = 0; led2 = 0; led3 = low; led4 = max; break; case 5: led1 = 0; led2 = 0; led3 = 0; led4 = max; break; case 6: led1 = 0; led2 = 0; led3 = 0; led4 = max; break; case 7: led1 = 0; led2 = 0; led3 = max; led4 = medium; break; case 8: led1 = 0; led2 = max; led3 = medium; led4 = low; break; case 9: led1 = max; led2 = medium; led3 = low; led4 = 0; break; case 10: led1 = max; led2 = low; led3 = 0; led4 = 0; break; case 11: led1 = max; led2 = 0; led3 = 0; led4 = 0; break; } } }