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:
- YPROY
- Date:
- 2017-01-30
- Revision:
- 0:7a91558f8c41
- Child:
- 1:df2cee74ab8b
File content as of revision 0:7a91558f8c41:
#include "mbed.h"
PwmOut mypwm(PA_7);
InterruptIn monBouton(USER_BUTTON);
int compteur;
int cycle[]={700, 1550, 2500, 1550};
void pressed(void)
{
compteur++;
if (compteur >= sizeof(cycle)/sizeof(int))
{
compteur = 0;
}
mypwm.pulsewidth_us(cycle[compteur]);
}
DigitalOut myled(LED1);
int main() {
compteur = 0;
mypwm.period_ms(20);
mypwm.pulsewidth_us(500);
// printf("pwm set to %.2f %%\n", mypwm.read() * 100);
monBouton.fall(&pressed);
while(1) {
myled = !myled;
wait(1);
}
}