I'd like to make an Arduino play a (2sec).wav file once when it is powered on (via push button) and another when it is switched off i.e. when the push button is pushed there is a 2sec delay and the .wav file plays, then the arduino turns off. What would the best way be to implement this? So far I've come up with:
void loop()
{
//play .wav file
while(1){}
}
or:
void setup(){
//play .wav file
}
void loop(){
//empty
}