#include <Plaquette.h>
Chronometer buttonChrono; // to mark time since a button is pressed
Chronometer mainChrono; // to mark time since the program started
DigitalIn button (2, INTERNAL_PULLUP);
Monitor monitor(9600); // to visualize the results of both Chronometer objects
Metronome monitorMetro (1.0); //to make reading the values easier
void begin() {
mainChrono.start();
button.debounce();
}
void step() {
if (button.rose()) {
buttonChrono.start(); // Start/restart this chronometer timer when the button is pressed
}
if (button.fell()) {
buttonChrono.pause(); // stop the Chronometer while preserving the last value
print ("Seconds that the button was held down");
println (buttonChrono);
}
if (monitorMetro) {
if (button) // if button == 1 the button is being pressed
println ("Button is being pressed");
else { // the button is not being held down
print ("Seconds since program began: ");
println (mainChrono);
}
}
}