quentin godbert
/
t2-stm32_thread
avec thread
Fork of T2_STM32 by
pwm.h@2:ab0ccf9bb38c, 2018-01-14 (annotated)
- Committer:
- Tioneb
- Date:
- Sun Jan 14 15:50:49 2018 +0000
- Revision:
- 2:ab0ccf9bb38c
- Child:
- 4:b01a3ce6ef01
Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Tioneb | 2:ab0ccf9bb38c | 1 | #include "mbed.h" |
Tioneb | 2:ab0ccf9bb38c | 2 | |
Tioneb | 2:ab0ccf9bb38c | 3 | //SAVE_TEST 2 |
Tioneb | 2:ab0ccf9bb38c | 4 | |
Tioneb | 2:ab0ccf9bb38c | 5 | PwmOut mypwm(PWM_OUT); |
Tioneb | 2:ab0ccf9bb38c | 6 | |
Tioneb | 2:ab0ccf9bb38c | 7 | DigitalOut myled(LED1); |
Tioneb | 2:ab0ccf9bb38c | 8 | |
Tioneb | 2:ab0ccf9bb38c | 9 | int main() { |
Tioneb | 2:ab0ccf9bb38c | 10 | |
Tioneb | 2:ab0ccf9bb38c | 11 | mypwm.period_ms(10); |
Tioneb | 2:ab0ccf9bb38c | 12 | mypwm.pulsewidth_ms(1); |
Tioneb | 2:ab0ccf9bb38c | 13 | |
Tioneb | 2:ab0ccf9bb38c | 14 | printf("pwm set to %.2f %%\n", mypwm.read() * 100); |
Tioneb | 2:ab0ccf9bb38c | 15 | |
Tioneb | 2:ab0ccf9bb38c | 16 | while(1) { |
Tioneb | 2:ab0ccf9bb38c | 17 | myled = !myled; |
Tioneb | 2:ab0ccf9bb38c | 18 | wait(1); |
Tioneb | 2:ab0ccf9bb38c | 19 | } |
Tioneb | 2:ab0ccf9bb38c | 20 | } |