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.
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.
9V batteries can supply very little current they will go flat in no time.
You have about a 650mA limit on the current the on board regulator can supply. Power Examples
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.
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?
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.
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.
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).
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?