#include <Plaquette.h>
Metro countdownMetro(0.2);
Metro loopMetro(0.5);
DigitalOut redLED(13);
int countdown = 10;
void begin() {
println("hello"); // Plaquette begins Serial at 9600 automatically. Just need to call print.
}
void step() {
if (loopMetro){ // this is a general metro so you don't over ping your Arduino processor. It also makes looking at your serial monitor less painful.
printCount(); // you can name each function whatever you want
toggleLED();
}
countDown();
}
///***********FUNCTIONS CAN GO ABOVE OR BELOW MAIN CODE LOOP *********//////
///void just means that the function doesn't return a value when it completes.
void printCount() {
print ("Here is the countdown ");
println(countdown); //print where the countdown is at
}
void toggleLED() {
println("it's fun to use functions for debugging and code readability");
redLED.toggle();
}
void countDown() {
if (countdownMetro)
countdown--; // subtract 1 every time the metro bangs with --
if (countdown <= 0) {
println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
println("Have a nice day!");
println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
countdown = 10; // reset the countdown
}
}