Mechatro example program
main.cpp@0:a17e11284fc5, 2017-10-05 (annotated)
- Committer:
- ykuroda
- Date:
- Thu Oct 05 07:50:42 2017 +0000
- Revision:
- 0:a17e11284fc5
1st commit;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ykuroda | 0:a17e11284fc5 | 1 | // Motor Control ... Mechatronics example program |
| ykuroda | 0:a17e11284fc5 | 2 | // |
| ykuroda | 0:a17e11284fc5 | 3 | // 2017.10.05 ... Y.Kuroda |
| ykuroda | 0:a17e11284fc5 | 4 | // |
| ykuroda | 0:a17e11284fc5 | 5 | #include "mbed.h" |
| ykuroda | 0:a17e11284fc5 | 6 | |
| ykuroda | 0:a17e11284fc5 | 7 | PwmOut a1(D1); |
| ykuroda | 0:a17e11284fc5 | 8 | DigitalOut a2(D12); |
| ykuroda | 0:a17e11284fc5 | 9 | |
| ykuroda | 0:a17e11284fc5 | 10 | int main() { |
| ykuroda | 0:a17e11284fc5 | 11 | |
| ykuroda | 0:a17e11284fc5 | 12 | a1.period_ms(1); |
| ykuroda | 0:a17e11284fc5 | 13 | |
| ykuroda | 0:a17e11284fc5 | 14 | while(1) { |
| ykuroda | 0:a17e11284fc5 | 15 | a1 = 0.1; // duty is 10% |
| ykuroda | 0:a17e11284fc5 | 16 | a2 = 0; |
| ykuroda | 0:a17e11284fc5 | 17 | wait(3); // 3 s |
| ykuroda | 0:a17e11284fc5 | 18 | |
| ykuroda | 0:a17e11284fc5 | 19 | a1 = 0.9; // duty is 10%!!! |
| ykuroda | 0:a17e11284fc5 | 20 | a2 = 1; |
| ykuroda | 0:a17e11284fc5 | 21 | wait(3); // 3 sec |
| ykuroda | 0:a17e11284fc5 | 22 | } |
| ykuroda | 0:a17e11284fc5 | 23 | } |
Yoji KURODA