Making a Hand? First Arduino Project; Need Help!

Hey guys/girls, I am new here and i am making my first arduino project; that includes making a hand that responds to a control glove that I make; i.e. when you move your fingers so does the hand. It works by using a flex sensor that that turns the shaft of a servo relative to the amount the sensor is bent, this is done five times (for five fingers). but my problem is that this is my first arduino project and I have only used programming languages python and turing so I have no experience in programming in the sort of matter and barely know what im doing. the code I have made for my project is a hybrid of this site learning section and someone else's code.

So what I am really asking you is if you can go over what I have so far and if you can tell me I what my code is doing corresponds to the circuit I built and what I need it to do. Here is the diagram and the code I have made. Please and thank you in advance.

My Diagram;

My Code;

Servo myservo1; 
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;

int Finger1 = 0;
int Finger2 = 1;
int Finger3 = 2;
int Finger4 = 3;
int Finger5 = 4;

int FingerV1; 
int FingerV2; 
int FingerV3; 
int FingerV4; 
int FingerV5;

void setup()
{
  myservo1.attach(2); 
  myservo2.attach(3);
  myservo3.attach(4);
  myservo4.attach(5);
  myservo5.attach(6);
}

void loop()
{
  int FingerV1 = analogRead(Finger1);
  int FingerV2 = analogRead(Finger2);
  int FingerV3 = analogRead(Finger3);
  int FingerV4 = analogRead(Finger4);
  int FingerV5 = analogRead(Finger5);

  FingerV1 = map(FingerV1,460, 200, 255, 0);
  FingerV2 = map(FingerV2,460, 200, 255, 0);
  FingerV3 = map(FingerV3,460, 200, 255, 0);
  FingerV4 = map(FingerV4,460, 200, 255, 0);
  FingerV5 = map(FingerV5,460, 200, 255, 0);
  
  myservo1.write(FingerV1);
  myservo2.write(FingerV2);
  myservo3.write(FingerV3);
  myservo4.write(FingerV4);
  myservo5.write(FingerV5);

  delay(100);
}

I would not expect that to work because you are running five servo motors from the USB power. First of all USB power is limited to 500mA so that is only 100mA per servo which is way too little for most servos. Second servos generate lots of interference and it is best to apply lots of decoupling or use a separate supply or both.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

You will get better help if you describe what is actually going wrong rather than saying "look over my work".

Which is why I am hooking up a 9v battery through a 2.1mm center-positive plug into the board's power jack. And what I am asking for help here is if my code actually do what i want to do, cause i have never used this language before. Btw; thanks for your feed back.

Which is why I am hooking up a 9v battery through

Ok even worse

  1. 9V batteries can supply very little current they will go flat in no time.
  2. You have about a 650mA limit on the current the on board regulator can supply.
    Power Examples
  3. You are powering the arduino and servo off the same supply, lots of users find that the interference will cause the arduino to keep on resetting.

The code looks quite un remarkable and apart for missing out the #include on the servo library should do what you want providing you have the mapping function right. What values are you reading from your pots? What values will your servos take?

Are you talking about the "Serial.begin(9600)", cause this is my first time programming with language ever, so i don't really know what your talking about (sorry about that). but for the power problem would it help if I used a battery for the flex sensors and the arduino and a separate battery for the servos both 9v?

Btw the way the original project code was done here;

but he is made a wireless version while i am try to make a wired one.

Are you talking about the "Serial.begin(9600)"

No.
You are not using the serial port so that is not relevant.

One of the first lines in the code should be:-
#include <Servo.h>
to add the extra servo functions.

Btw the way the original project code was done here

Note that instructable projects are almost always total pants.

but for the power problem would it help if I used a battery for the flex sensors and the arduino and a separate battery for the servos both 9v?

Not much 9V batteries and motors do not go well together unless you are very rich and don't mind changing them every 5 minutes. Also then you would be powering the servos with 9V, what voltage do they need?

The servo I plan to build with is;

and about that line you were talking about do you mean "#include <SoftwareServo.h>" or something like "SoftwareServo myservo;"

Once you find yourself writing the same bit of code with minor differences, it is time to look at loops and arrays:
(uncompiled, untested)

const int N_SERVOS = 5;
Servo myservo[N_SERVOS]; 
const int fingerPin [N_SERVOS]   = {0, 1, 2, 3, 4};
const int servoPin [N_SERVOS] = {2, 3, 4, 5, 6};

void setup()
{
  for (int i = 0; i < N_SERVOS; ++i) {
    myservo[i].attach(servoPin [i]); 
  }   
}

void loop()
{
  for (int i = 0; i < N_SERVOS; ++i) {
    int fingerVal = analogRead(fingerPin [i]);
 
    fingerVal = map(fingerVal,460, 200, 255, 0);
  
    myservo[i].write(fingerVal);
  }
  delay(100);
}

I get the feeling that you haven't even tried to compile you code let alone run it. Get the code running, see what problems you have and then ask again. And you will be told the same things again.

Thank you so much for your feed back, but @AWOL wouldn't that piece of code restrict the hands movements to move one finger at a time, or am I wrong?

Yes, you are wrong.
It does only move one finger at a time, but then, so did your code.
However, compared to a processor executing instructions in the time it takes a beam of light to travel 20 metres, and a servo managing maybe 180 degrees a second (and only updating 50 times a second), as far as you're concerned, they all move simultaneously.

So what your saying is that your code executes faster than mine right? And if so why?

No, I didn't say it executes faster.
I said speed here (particularly when you have the processor twiddling its thumbs for a tenth of a second) is irrelevant.
However, the code is shorter, so it gives the bugs fewer dark corners to hide in.

Oh okay, now that makes sense, but other than my code being longer, and not having the "#include <SoftwareServo.h>"/"SoftwareServo::refresh();" what else is wrong with my code (or is it just sloppy).

but other than my code being longer, and not having the "#include <SoftwareServo.h>"/"SoftwareServo::refresh();"

Unless there is a good reason to use "SoftwareServo", I wouldn't bother - just use the ordinary Servo library shipped with the Arduino installation.

what else is wrong with my code (or is it just sloppy)

Not sloppy, but maybe not built with an eye for the future - imagine you want to add another six or seven joints.

Thank you so much for your feedback, it means a lot especially since I am just starting but if I could ask one more question, how would I go about fixing the power problem brought up by @Grumpy_Mike, would my idea of giving the arduino and servos there own independent power source work or will I have to find some other way to do it.

Also you mentioned that with your code I could add other joints to do that would I just alter the array in your code and add one analog input/one digital output?

Yes they need there own separate supply but the grounds need to be connected together.

So instead of taking out the ground and the 5v line from the servos I only remove the 5v line and add a power source like in here;

Yes.