Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
How to reset my timer read ?
Hello,
I want to count beetween 2 moments (first moment press center joystick and second moment press joystick up) , I have decided to use interrupt but my code on the LCD board count the first try between the 2 moments by when I do it again I make the sum of the time. I want to restart the count for the second try. How can I do this ? Here is my code.
Excuses my Englih, I am a french technicians and also beginner in mbed.
InterruptIn bouton(p14); déclaration de l'interruption bouton sur la pin14 C12832 lcd(p5, p7, p6, p8, p11); déclaration des pins du LCD
Timer t; déclaration d'une variable t de type timmr void mesureBouton(void); déclaration de la fonction mesureButon void mesureCellule(void); déclaration de la fonction mesureCellule bool finMesure; déclaration d'un booléen FinMesure int main() { lcd.cls(); initialisation du LCD finMesure = 0; bouton.rise(&mesureBouton); cellule.rise(&mesureCellule); while(1) { if (finMesure == 1) { lcd.cls(); lcd.locate(0, 3); lcd.printf("la duree est de %f \n", t.read()); finMesure = 0; } }
}
Corps des fonctions mesureButon et mesureCellule void mesureBouton(void) {
t.start(); finMesure = 0;
void mesureCellule(void) { t.stop(); finMesure = 1;
}
Finally, I succeed, it was more easy than I thought, using t.reset(); it works.
posted by JULIEN PREUX 14 Feb 2017