Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
}
}