Arduino Muscle Sensor V3 signal AnalogRead issue

Hi,

I am trying to send signals from the muscle signal sensor to the servo motors as follows
My problem is I can’t get these signals right. Servo motors turn ridiculous.
I made all the connections right.
Ardiuno Uno yazılım kartını kullanıyorum.

#include <Servo.h>
 
#define THRESHOLD 150 
#define EMGPIN 3 //Analog pin connected to Muscle Sensor V3 Board
#define LITTLEPIN  3 //Digital pin used by Little servo
#define RINGPIN    5 //Digital pin used by Ring servo
#define MIDDLEPIN  6 //Digital pin used by Middle servo
#define INDEXPIN   9 //Digital pin used by Index servo
#define THUMBPIN  10 //Digital pin used by Thumb servo
 
//Constants used to open and close the fingers
#define LITTLE 1 
#define RING   2
#define MIDDLE 3
#define INDEX  4
#define THUMB  5
 
Servo servoLittleFinger;         // Define servo fingers
Servo servoRingFinger;         // Define servo fingers
Servo servoMiddleFinger;         // Define servo fingers
Servo servoIndexFinger;         // Define servo fingers
Servo servoThumbFinger;         // Define servo fingers
 
int finger;
 
// Motion routines for handopen and handclose
void openhand(){for(finger = 1; finger < 6; finger++){openFinger(finger);}}
void closehand(){for(finger = 1; finger < 6 ; finger++){closeFinger(finger);}}
 
 
void openFinger(int finger){
  if(finger==LITTLE){servoLittleFinger.write(0);} // Little finger
  else if(finger==RING){servoRingFinger.write(170);}// Ring finger
  else if(finger==MIDDLE){servoMiddleFinger.write(170);}// Middle finger
  else if(finger==INDEX){servoIndexFinger.write(170);}// Index finger
  else if(finger==THUMB){servoThumbFinger.write(0);}//Thumb finger
}
 
void closeFinger(int finger){
  if(finger==LITTLE){servoLittleFinger.write(170);} // Little finger 
  else if(finger==RING){servoRingFinger.write(0);}// Ring finger
  else if(finger==MIDDLE){servoMiddleFinger.write(0);}// Middle finger
  else if(finger==INDEX){servoIndexFinger.write(0);}// Index finger
  else if(finger==THUMB){servoThumbFinger.write(170);}//Thumb finger
}
 
void setup(){
   
  Serial.begin(115200); 
 
  servoLittleFinger.attach(LITTLEPIN);  // Set Little finger servo to digital pin 3
  servoRingFinger.attach(RINGPIN);  // Set Ring finger servo to digital pin 5
  servoMiddleFinger.attach(MIDDLEPIN);  // Set Middle finger servo to digital pin 6
  servoIndexFinger.attach(INDEXPIN);  // Set Index finger servo to digital pin 9
  servoThumbFinger.attach(THUMBPIN);  // Set Thumb finger servo to digital pin 10
 
}//end setup
 
void loop() {// Nothing to do here, all is done in the interrupt function
 
  int value = analogRead(EMGPIN); //Sampling analog signal
  if(value>THRESHOLD) 
  {closehand();}
  else //Otherwise the hand is open
  {openhand();}
  Serial.println(value); 
}

Muscle sensor integrated diagram:

Where am I making a mistake? Can you help me please ?
Thanks.

emrecapan:

#define EMGPIN 3 //Analog pin connected to Muscle Sensor V3 Board

#define LITTLEPIN  3 //Digital pin used by Little servo

And how do you expect your code to distinguish between the former 3 and the latter 3? Your analogRead(EMGPIN) reads the same pin that your servo is attached to. This makes no sense at all.

If your sensor is attached to analog input pin #3 that would be pin A3. A3, not just 3. Yet in your picture it seems to be attached to pin A0.

What is this mess? Where is your sensor actually attached?

emrecapan:

void loop() {// Nothing to do here, all is done in the interrupt function

What is that comment supposed to mean?

emrecapan:
Servo motors turn ridiculous.

And what is that supposed to mean?

And how do you expect your code to distinguish between the former 3 and the latter 3? Your analogRead(EMGPIN) reads the same pin that your servo is attached to. This makes no sense at all.

In your sensor is attached to analog input pin #3 that would be pin A3. A3, not just 3. Yet in your picture it seems to be attached to pin A0.

What is this mess? Where is your sensor actually attached?

I changed the A3 and tried again the same problem

Quote from: emrecapan on Today at 10:41 pm
Code: [Select]

void loop() {// Nothing to do here, all is done in the interrupt function

What is that comment supposed to mean?

I have no idea. I found this code on the internet.

Thanks for reply

emrecapan:
I changed the A3 and tried again the same problem

Once again: which analog input pin is your sensor connected to? Why is your picture showing A0? Why did you try A3?

it's just a template