Example code 12

Dependencies:   mbed-rtos mbed

Fork of STMNucleoF401RE_ExampleCode_12_ServoMotor by 20161020-Corso Rapid Prototyping with STM32Nucleo

Circuito

/media/uploads/perlatecnica/servomotorepotenziometro.png

Committer:
bcostm
Date:
Wed Feb 12 15:34:26 2014 +0000
Revision:
0:4860a91fb495
Child:
2:e1a0d442f750
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:4860a91fb495 1 #include "mbed.h"
bcostm 0:4860a91fb495 2
bcostm 0:4860a91fb495 3 PwmOut mypwm(PWM_OUT);
bcostm 0:4860a91fb495 4
bcostm 0:4860a91fb495 5 DigitalOut myled(LED1);
bcostm 0:4860a91fb495 6
bcostm 0:4860a91fb495 7 int main() {
bcostm 0:4860a91fb495 8
bcostm 0:4860a91fb495 9 mypwm.period_ms(10);
bcostm 0:4860a91fb495 10 mypwm.pulsewidth_ms(1);
bcostm 0:4860a91fb495 11
bcostm 0:4860a91fb495 12 printf("pwm set to %.2f %%\n", mypwm.read() * 100);
bcostm 0:4860a91fb495 13
bcostm 0:4860a91fb495 14 while(1) {
bcostm 0:4860a91fb495 15 myled = !myled;
bcostm 0:4860a91fb495 16 wait(1);
bcostm 0:4860a91fb495 17 }
bcostm 0:4860a91fb495 18 }