how to measure the Differential of EMG signal input

i am trying to measure EMG signal using MYOWARE and its Differential input to determine whenever the difference is high, the program triggers a certain command. will this code works?

basically i want to have the MCU detect whenever the muscle flexes, and extends

void loop() {

emg = analogRead(emgPin);

emg2= analogRead(emgPin);

change = emg2 - emg; // differential value

if (change > 200){
//insert command

diff_EMG.ino (286 Bytes)

If you are afraid to test it, have a friend do it.


It would be good practice to name and define the threshold value at the top of the file, since the
number 200 in the middle of the code is pretty obscure.

#define THRESHOLD_VOLTAGE_DIFF 0.97   // or whatever voltage is correct...


if (change > THRESHOLD){