I am new to arduino, I am making an interactive device that will blink when the person touches it and it will make a sound. I derived a sensor and it is connected to the arduino through pin 9, which is based on a voltage divider circuit. The human makes contact and is part of the circuit , thereby lowering the voltage input to Pin 9. This in turn makes the Catalex Mp3 player play a sound until the condition is false (there is a safety margin in the values stored where there is nothing happening to prevent crazy floating action lines 6 and 7). I'm sure there is a better way. But the real issue is my code in line 95. I tell it to send a command to play and it is constantly resending the command which I think is causing some weird sound issues. But all else, it works fine. Can someone help me? Thanks in advance!
}
// if the analog value is low enough (human contact), blink lights and activiate sound effect:
if (analogValue < lowerthreshold) {
sendCommand(CMD_PLAY, 0);
digitalWrite(ledPin, HIGH);
delay (50);
digitalWrite (ledPin, LOW);
delay (50);
}
// if the analog value is high enough (no contact), turn off the blinking lights and sound:
else //(analogValue > upperthreshold)
{
sendCommand(CMD_PAUSE, 0);
digitalWrite(ledPin, LOW);}
// print the analog value:
//Serial.println(analogValue); comment out to avoid too much information in serial, uncomment to read value ( calibrate sensors )
delay(1); // delay in between reads for stability
}