we all started somewhere. Don't feel bad.
if you want to get rid of the timer, you can do this
#include <M5Stack.h>
char currentCharEffect = '\0'; // none
int currentVolume = 0; // OFF
unsigned long lastTrigger;
const unsigned long period = 5000;
void playWAV (char effect, int volume)
{
...
}
void setup() {
M5.begin();
lastTrigger = millis();
}
void loop() {
if (millis() - lastTrigger >= period) {
lastTrigger = millis();
playWAV(currentCharEffect, currentVolume);
}
// here some code modifying currentCharEffect and currentVolume
}