sfrgv
Dependencies: mbed
main.cpp
- Committer:
- chifterben94
- Date:
- 2017-02-01
- Revision:
- 0:5f492aa92a41
File content as of revision 0:5f492aa92a41:
#include "mbed.h" //--------------------------------------------- VARIABLES ET CLASSES Ticker ticker; Timer timer; Serial pc(USBTX,USBRX); InterruptIn bouton(USER_BUTTON); int transmissionActive = 0; static char nombreAEnvoyer = '0'; //--------------------------------------------- ENVOYER void envoyerNombre(){ if(transmissionActive == 1) { pc.putc(nombreAEnvoyer); nombreAEnvoyer ++; if (nombreAEnvoyer > '9') { nombreAEnvoyer = '0'; } } } //--------------------------------------------- ARRETER L'ENVOI void stopEnvoie(){ transmissionActive = 0; } //--------------------------------------------- MAIN int main() { ticker.attach(&envoyerNombre,1); while(1) { if(bouton == 0) { timer.reset(); nombreAEnvoyer = '0'; transmissionActive = !transmissionActive; while (bouton == 0){} timer.start(); } if (timer.read() == 10) { stopEnvoie(); } } } //---------------------------------------------