The filters work only with fixed sample frequency of
`SAMPLE_FREQ_500HZ` or `SAMPLE_FREQ_1000HZ`.
Inputs at other sample rates will bypass
*/
SAMPLE_FREQUENCY sampleRate = SAMPLE_FREQ_500HZ;
/*
Set the frequency of power line hum to filter out.
For countries with 60Hz power line, change to "NOTCH_FREQ_60HZ"
*/
NOTCH_FREQUENCY humFreq = NOTCH_FREQ_50HZ;
void setup()
{
myFilter.init(sampleRate, humFreq, true, true, true);
Serial.begin(115200);
}
void loop()
{
int data = analogRead(SensorInputPin);
int dataAfterFilter = myFilter.update(data); // filter processing
int envelope = sq(dataAfterFilter); //Get envelope by squaring t
he input
envelope = (envelope > threshold) ? envelope : 0; // The data s
et below the base value is set to 0, indicating that it is in a rela
xed state
/* if threshold=0,explain the status it is in the calibration proc
ess,the code bollow not run.
if get EMG singal,number++ and print
*/
if (threshold > 0)
{
if (getEMGCount(envelope))
{
EMG_num++;