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.
Dependencies: mbed
main.cpp
- Committer:
- dg81
- Date:
- 2020-05-04
- Revision:
- 1:7d73836cc7c6
- Parent:
- 0:75ca8f5758b2
File content as of revision 1:7d73836cc7c6:
#include "mbed.h"
PwmOut led(D3);
int main() {
// specify period first
led.period(0.01); // 4 second period
led.write(0.50); // 50% duty cycle, relative to period
//led = 0.5f; // shorthand for led.write()
//led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds
while(1){
led.write(0.25); // 50% duty cycle, relative to period
wait(2);
led.write(0.5); // 50% duty cycle, relative to period
wait(2);
led.write(0.75); // 50% duty cycle, relative to period
wait(2);
}
}