Hi
I’m trying to get a track play and stop using a piezo. I can get to play with the following code but the
player.opPause(); returns
‘undefined reference to `ctrlState’ error message
can you please point me in the right direction?
Cheers
#include <SD.h>
#include <SPI.h>
#include <arduino.h>
#include <MusicPlayer.h>
const int analogInPin = A4; // Analog input pin that the potentiometer is attached to
int sensorValue = 0;
void setup(void)
{
Serial.begin(9600);
player.begin(); //will initialize the hardware and set default mode to be normal.
player.addToPlaylist(“walking”);
player.setPlayMode(PM_REPEAT_LIST);
player.keyDisable(); //keys disable first;
player.analogControlEnable(); //enable to scan the A4/A5
//will initialize the hardware and set default mode to be normal.
player.attachAnalogOperation(A4, adjustVolume);
}
void loop(void)
{
adjustVolume();
}
void adjustVolume(void) //User-defined function
{
int sensorValue = analogRead(analogInPin);
Serial.println(sensorValue);
if (sensorValue >=10)
player.play();
else
player.opPause();
}