moter
Dependencies: mbed
main.cpp@0:e0341ee3f039, 2016-05-31 (annotated)
- Committer:
- Nike3221
- Date:
- Tue May 31 13:14:15 2016 +0000
- Revision:
- 0:e0341ee3f039
moter
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nike3221 | 0:e0341ee3f039 | 1 | #include "mbed.h" |
Nike3221 | 0:e0341ee3f039 | 2 | |
Nike3221 | 0:e0341ee3f039 | 3 | Serial pc(USBTX, USBRX); |
Nike3221 | 0:e0341ee3f039 | 4 | DigitalOut myled(LED1); |
Nike3221 | 0:e0341ee3f039 | 5 | DigitalIn in1(p5); |
Nike3221 | 0:e0341ee3f039 | 6 | DigitalOut out1(p6); |
Nike3221 | 0:e0341ee3f039 | 7 | PwmOut moter(p21); |
Nike3221 | 0:e0341ee3f039 | 8 | |
Nike3221 | 0:e0341ee3f039 | 9 | int main() |
Nike3221 | 0:e0341ee3f039 | 10 | { |
Nike3221 | 0:e0341ee3f039 | 11 | float i; |
Nike3221 | 0:e0341ee3f039 | 12 | while(1) { |
Nike3221 | 0:e0341ee3f039 | 13 | i=0.0; |
Nike3221 | 0:e0341ee3f039 | 14 | /*out1=0; |
Nike3221 | 0:e0341ee3f039 | 15 | if(in1==1) |
Nike3221 | 0:e0341ee3f039 | 16 | {*/ |
Nike3221 | 0:e0341ee3f039 | 17 | while(i<=0.8) |
Nike3221 | 0:e0341ee3f039 | 18 | {moter.period(0.02); |
Nike3221 | 0:e0341ee3f039 | 19 | moter.pulsewidth(i); |
Nike3221 | 0:e0341ee3f039 | 20 | i=i+0.005; |
Nike3221 | 0:e0341ee3f039 | 21 | pc.printf("%f\n",i); |
Nike3221 | 0:e0341ee3f039 | 22 | wait(0.3);} |
Nike3221 | 0:e0341ee3f039 | 23 | //} |
Nike3221 | 0:e0341ee3f039 | 24 | |
Nike3221 | 0:e0341ee3f039 | 25 | } |
Nike3221 | 0:e0341ee3f039 | 26 | } |