LED output example l by Soft PWM.
Fork of pwmLED by
main.cpp@1:155dd5b24708, 2013-10-24 (annotated)
- Committer:
- komaida424
- Date:
- Thu Oct 24 15:52:28 2013 +0000
- Revision:
- 1:155dd5b24708
- Parent:
- 0:b3a395ee08f3
LED output example by SoftPWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
suikan | 0:b3a395ee08f3 | 1 | #include "mbed.h" |
suikan | 0:b3a395ee08f3 | 2 | #include "math.h" |
komaida424 | 1:155dd5b24708 | 3 | #include "SoftPWM.h" |
suikan | 0:b3a395ee08f3 | 4 | |
komaida424 | 1:155dd5b24708 | 5 | SoftPWM led[] = { LED1,LED2,LED3,LED4 }; |
suikan | 0:b3a395ee08f3 | 6 | |
komaida424 | 1:155dd5b24708 | 7 | int main() |
komaida424 | 1:155dd5b24708 | 8 | { |
komaida424 | 1:155dd5b24708 | 9 | for ( int i=0; i<4; i++ ) led[i].period_ms( 1 ); |
komaida424 | 1:155dd5b24708 | 10 | while (1) { |
komaida424 | 1:155dd5b24708 | 11 | for ( int j=0; j<360; j+=10 ) { |
komaida424 | 1:155dd5b24708 | 12 | for ( int k=0; k<4; k++ ) { |
komaida424 | 1:155dd5b24708 | 13 | led[k] = cos( (j+k*90)*2.0*3.14/360 ) * 0.5 + 0.5; |
komaida424 | 1:155dd5b24708 | 14 | wait(0.01); |
komaida424 | 1:155dd5b24708 | 15 | } |
suikan | 0:b3a395ee08f3 | 16 | } |
komaida424 | 1:155dd5b24708 | 17 | } |
suikan | 0:b3a395ee08f3 | 18 | } |