#define PLAY_BLANK_DELAY 1000 // Blanking when playing a sound (ms)
#define DELAY_MP3_RESET 100 // Time of ground cut of MP3 module for re-init (ms)
//Calibration constants : do adjust :-)
//#define MP3_RESET
//#define DEBUG_UART_ACCELEROMETER // Warning : conflict with MP3 player
#define PLAY_BLANK_DELAY 1000 // Blanking when playing a sound (ms): Must be longer than the played sample (recommended : sample duration + 100ms)
#define DELAY_MP3_RESET 100 // Time of ground cut of MP3 module for re-init (ms) : Adjust only if hardware proiblems with new revisions of the mp3 module
#define DEBOUNCE_DELAY 200 // Position sensor input debounce (ms)
#define DEBOUNCE_DELAY 200 // Position sensor input debounce (ms)
#define ACCEL_THRES_GYX 1000
#define ACCEL_THRES_GYX 1000 // Detection threshold for X axis acceleration
#define ACCEL_THRES_GYY 1000
#define ACCEL_THRES_GYY 1000 // Detection threshold for Y axis acceleration
#define ACCEL_THRES_GYZ 1000
#define ACCEL_THRES_GYZ 1000 // Detection threshold for Z axis acceleration
// Typedefs
// Typedefs
// Main state machine : start actions
typedefenum
typedefenum
{
{
//Initialisation
STM_INIT,
STM_INIT,
//Wainting for input (capteur)
STM_IDLE,
STM_IDLE,
//When input, play sample
STM_PLAY,
STM_PLAY,
//Waiting after playing sample
STM_BLANK,
STM_BLANK,
//Optional hardware reset of the MP3 module (See calibration constants for activation)
STM_MP3_RESET,
STM_MP3_RESET,
}tStateMachine;
}tStateMachine;
...
@@ -87,21 +97,22 @@ void setup() {
...
@@ -87,21 +97,22 @@ void setup() {
// Reserve 200 bytes for the inputString:
// Reserve 200 bytes for the inputString:
inputString.reserve(200);
inputString.reserve(200);
// Position sensor input pin - D9 - Input pull-up
// Position sensor input pin - See hardware constants for pin definition - Input pull-up
pinMode(PIN_SENSOR_POSITION,INPUT_PULLUP);
pinMode(PIN_SENSOR_POSITION,INPUT_PULLUP);
// Touch sensor 1 input pin - D8 - Input no pull
// Touch sensor 1 input pin - See hardware constants for pin definition - Input no pull
pinMode(PIN_TOUCH_SENSOR1,INPUT);
pinMode(PIN_TOUCH_SENSOR1,INPUT);
// Touch sensor 2 input pin - D5 - Input no pull
// Touch sensor 2 input pin - See hardware constants for pin definition - Input no pull