thibault lottin
/
TP4_exo2
Revision 0:bdc5c9b6ed5e, committed 2014-10-23
- Comitter:
- mbedo
- Date:
- Thu Oct 23 12:17:57 2014 +0000
- Commit message:
- TP4_exo2
Changed in this revision
Progression_Moteur_Weylot.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 bdc5c9b6ed5e Progression_Moteur_Weylot.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Progression_Moteur_Weylot.cpp Thu Oct 23 12:17:57 2014 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" + +InterruptIn accelerateur(p15); // Nos 2 boutons qui serviront d'interruptions (accéleration, ralentissement) +InterruptIn ralentisseur(p18); + +PwmOut moteur1(p21); // On utilisera que le moteur1 +PwmOut moteur2(p22); +float pwm; // On initialise une variable flottante pwm + +void regulateur () // On crée une nouvelle fonction : régulateur + +{ + if (accelerateur==0) {// Si le bouton accéllerateur est enclenché + if (pwm<1.0) // et si la vitesse du moteur n'est pas à son maximum + pwm=pwm+0.05; // alors le moteur voit sa vitesse augmentée de 5% + moteur1=pwm; + } + if(ralentisseur==0) { // A l'inverse si la touche ralentisseur est enclenché et que + if (pwm>0.0) // le moteur n'a pas une vitesse nulle + pwm=pwm-0.2; // alors le moteur voit sa vitesse baissée de 20% à chaque appui + moteur1=pwm; + } +} + +int main () +{ + accelerateur.fall(®ulateur); // La fonction régulateur intervient lorsqu'un des 2 boutons est enclenché + ralentisseur.fall(®ulateur); + while(1) + {} +} \ No newline at end of file
diff -r 000000000000 -r bdc5c9b6ed5e mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 23 12:17:57 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file