richard tsai / Mbed 2 deprecated Nucleo_pwm

Dependencies:   mbed

main.cpp

Committer:
hungkait
Date:
2014-08-13
Revision:
2:95aadb46a806
Parent:
1:5ed69f730858

File content as of revision 2:95aadb46a806:

#include "mbed.h"
 
Ticker flipper;
PwmOut mypwm(PWM_OUT);
DigitalOut led1(LED1);
DigitalOut led2(LED2);

//DigitalOut myled(LED1);

void flip() {
    led2 = !led2;
}
 
int main() {
    
    mypwm.period_ms(10);
    mypwm.pulsewidth_ms(1);
    
    flipper.attach(&flip, 4.0); // the address of the function to be attached (flip) and the interval (2 seconds)
  
    printf("pwm set to %.2f %%\n", mypwm.read() * 100);
    
    // spin in a main loop. flipper will interrupt it to call flip
    while(1) {
        led1 = !led1;
        wait(0.2);
    }
}