Joel Manuel Fernandez Cuyubamba
/
Partie4
exercice6.cpp@0:e54fcd358582, 2016-05-02 (annotated)
- Committer:
- jomfec
- Date:
- Mon May 02 09:05:23 2016 +0000
- Revision:
- 0:e54fcd358582
INFO2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jomfec | 0:e54fcd358582 | 1 | /* |
jomfec | 0:e54fcd358582 | 2 | #include "mbed.h" |
jomfec | 0:e54fcd358582 | 3 | InterruptIn bouton(p18); //définition de p18 comme entrée d’interruption |
jomfec | 0:e54fcd358582 | 4 | DigitalOut sortie1(p5); |
jomfec | 0:e54fcd358582 | 5 | Timer antirebond; // définition du Timer antirebond |
jomfec | 0:e54fcd358582 | 6 | void toggle(void); // prototype de toggle |
jomfec | 0:e54fcd358582 | 7 | int main() |
jomfec | 0:e54fcd358582 | 8 | { |
jomfec | 0:e54fcd358582 | 9 | bouton.mode(PullUp); |
jomfec | 0:e54fcd358582 | 10 | antirebond.start(); |
jomfec | 0:e54fcd358582 | 11 | bouton.rise(&toggle); //attache l’adresse de la fonction au front montant du bouton |
jomfec | 0:e54fcd358582 | 12 | |
jomfec | 0:e54fcd358582 | 13 | while(1) |
jomfec | 0:e54fcd358582 | 14 | { |
jomfec | 0:e54fcd358582 | 15 | //Programme principal |
jomfec | 0:e54fcd358582 | 16 | } |
jomfec | 0:e54fcd358582 | 17 | } |
jomfec | 0:e54fcd358582 | 18 | void toggle() |
jomfec | 0:e54fcd358582 | 19 | { |
jomfec | 0:e54fcd358582 | 20 | |
jomfec | 0:e54fcd358582 | 21 | if (antirebond.read_ms()>200) //autorisation de l’inversion seulement |
jomfec | 0:e54fcd358582 | 22 | { |
jomfec | 0:e54fcd358582 | 23 | sortie1.write(!sortie1.read()); //si le Timer a dépassé 200ms |
jomfec | 0:e54fcd358582 | 24 | antirebond.reset(); //Remise à zéro du Timer |
jomfec | 0:e54fcd358582 | 25 | } |
jomfec | 0:e54fcd358582 | 26 | } |
jomfec | 0:e54fcd358582 | 27 | |
jomfec | 0:e54fcd358582 | 28 | */ |