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
Revision 0:cce2fdfbfbc4, committed 2018-04-12
- Comitter:
- McCaron
- Date:
- Thu Apr 12 17:06:09 2018 +0000
- Commit message:
- pwm avec le bouton. commence a 0% monte a 100%. 1kHz
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r cce2fdfbfbc4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Apr 12 17:06:09 2018 +0000 @@ -0,0 +1,42 @@ +//_____________________________________________________________________________________ +//Noms: David Caron et Benoit Malenfant +//Date: 2018-04-12 +//TP-Nucleo +//Ce programe fait un PWM de 1kHz sur la broche D10, il commence a un duty cycle de 0 +//puis, chaque fois qu'on pese sur le bouton user, la duty cycle augmante de 1% +//_____________________________________________________________________________________ + +#include "mbed.h" //la librairie mbed +PwmOut monPWM(PB_6); //je dit ou je veut mon pwm, pwmsortant, le nom du pwm et sur quelle broche je le veut +DigitalIn bouton(USER_BUTTON); //je dit que jai une entrée digital qui rentre. je le nomme boutton, et c'est le bouton_user (Bouton bleu) + +float duty=0; //Je déclare un float pour mon duty cycle étant donner que la fonction que je vais utiliser prend des nombres a virgule et je le set a 0 + + +int main() +{ + monPWM.period(0.001); //set la periode a 1khz + while (1) + { + + + if(bouton==0) //si j'appuie sur le bouton + { + while(bouton==0) + { + //faire rien, attendre que le user lache le bouton comme sa j'ai pas a mettre de phase wait(x); + } + duty=duty+0.01; // zero a 1, on passe de 1% chaque fois + wait(0.01); //laisse le user enlever son doigt + } + + + if (duty>1) //Si le duty cycle est rendu a 100% fait l'actions prochaines: + { + (duty = 0); // descend le duty cycle a 0% + } + + monPWM.write(duty); //rentre le duty cycle dans le PWM + + } +} \ No newline at end of file
diff -r 000000000000 -r cce2fdfbfbc4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 12 17:06:09 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file