Yoshiyuki Takahashi
/
Y_03
Sequence LEDs
Fork of Y_01 by
Revision 3:a9682a192956, committed 2015-02-18
- Comitter:
- seethe
- Date:
- Wed Feb 18 07:53:17 2015 +0000
- Parent:
- 2:ce41adf02350
- Commit message:
- PWM
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ce41adf02350 -r a9682a192956 main.cpp --- a/main.cpp Wed Feb 18 06:44:13 2015 +0000 +++ b/main.cpp Wed Feb 18 07:53:17 2015 +0000 @@ -5,16 +5,18 @@ #define PI 3.1415 -//TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 AnalogIn in1(p15); AnalogIn in2(p16); AnalogIn in3(p17); -AnalogOut out(p18); +//AnalogOut out(p18); -DigitalOut DO[4]={LED1, LED2, LED3, LED4}; +PwmOut led(LED1); +PwmOut pwm(p21); + +//DigitalOut DO[4]={LED1, LED2, LED3, LED4}; //int nCnt; - +/* void led_blink(int cnt) { for(int n=0; n<4; n++){ @@ -22,14 +24,24 @@ else DO[n] = 0; } } +*/ int main() { int nCnt; double rad; double od; + pwm.period(0.001); nCnt = 0; rad = 0.0; + while(1) { + for(float p = 0.0f; p < 1.0f; p += 0.1f) { + led = pwm = p; + wait(0.1); + } + } + + /* while(1){ led_blink(nCnt); nCnt++; @@ -46,4 +58,5 @@ lcd.printf("%.3f\n", od); lcd.printf("%.2f,.%.2f,%.2f\n", in1.read(), in2.read(), in3.read()); } + */ }