Hello everyone
Full code, works great on another arduino mega, but on Arduino where it is located on the board it loads, but restarts arduino infinitely, loaded the microcontroller, another code works if you delete a line from the code
ELEMYO MyoSensor1(CSpin1); // create ELEMYO object to work with signal
ELEMYO MyoSensor2(CSpin2); // create ELEMYO object to work with signal
Arduino stops rebooting, but the code won't work
Full code:
#include <ELEMYO.h>
#define CSpin1 10
#define CSpin2 9
#define sensorInPin1 A2 // analog input pin that the 1st sensor is attached to
#define sensorInPin2 A1 // analog input pin that the 2nd sensor is attached to
int signalReference = 524; // reference of signal, 2.5 V for MYO, MYO-kit, BPM, BPM-kit
//int signalReference = 369; // reference of signal, 1.8 V for MH-BPS101 and MH-BPS102
ELEMYO MyoSensor1(CSpin1); // create ELEMYO object to work with signal
ELEMYO MyoSensor2(CSpin2); // create ELEMYO object to work with signal
short tr1 = 100; // trigger for 1st sensor
short tr2 = 100; // trigger for 2nd sensor
int kizil = 13;
void setup() {
Serial.begin(115200); // initialize serial communications at 115200 bps
MyoSensor1.gain(x4); // initial value of gain for 1st sensor
MyoSensor2.gain(x8); // initial value of gain for 2nd sensor
pinMode(sensorInPin1, INPUT); // initialize sensorInPin
pinMode(sensorInPin2, INPUT); // initialize sensorInPin
pinMode(kizil, OUTPUT);
}
//-------------!!! Calibrate gain for each sensor before start !!!---------------------------------------------------------------------------
void loop() {
//----reading and filtering signal of 1st sensor----
int signalValue1 = analogRead(sensorInPin1); // read the analog in value:
signalValue1 = MyoSensor1.BandStop(signalValue1, 50, 4); // notch 50 Hz filter with band window 4 Hz.
signalValue1 = MyoSensor1.BandStop(signalValue1, 100, 6); // notch 100 Hz (one of 50 Hz mode) filter with band window 6 Hz
signalValue1 = MyoSensor1.movingAverage(signalValue1, signalReference, 0.96); // moving average transformation with 0.96 smoothing constant
//--------------------------------------------
//----reading and filtering signal of 2nd sensor----
int signalValue2 = analogRead(sensorInPin2); // read the analog in value:
signalValue2 = MyoSensor2.BandStop(signalValue2, 50, 4); // notch 50 Hz filter with band window 4 Hz.
signalValue2 = MyoSensor2.BandStop(signalValue2, 100, 6); // notch 100 Hz (one of 50 Hz mode) filter with band window 6 Hz
signalValue2 = MyoSensor2.movingAverage(signalValue2, signalReference, 0.96); // moving average transformation with 0.96 smoothing constant
//--------------------------------------------
Serial.println(signalValue1);
if (signalValue1 > 130) {
digitalWrite(kizil, HIGH);
} else {
digitalWrite(kizil, LOW);
}
}
