Need some help for a science project.

I UNDERSTAND NOW!

awesome_smiley_sticker-p217764211963271445en7l1_216.jpeg

[highfive/]

Excellent....

Word of caution with servos: even tiny ones are quite strong and they move quite quickly.

Here's what I'd do: build a dummy "test" finger that you can afford to destroy if the servo goes wild... That way you won't rip your whole hand to pieces. Then set up a test rig with that finger and a servo mounted on a wooden frame or something, and or rope some folk in to hold stuff for you. Position the servo and its horn so that it looks like it will pull smoothly, then turn the servo motor by hand to test it, ie not under power! Note that where you push the horn onto the servo- called a spline- you can position the horn on the teeth to get the best angle.

You've used the sweep program you said?- so modify that just to sweep from say 0 to 10 and back. Increase the delay to much longer one just to be safe, and then make it smaller again once you check nothing is snagging. If you get a snag I think the servo might tear stuff, so be careful.

Well done so far... you're doing great and you get 10/10 for persistence!

Do you need help programming the Arduino?

I need all the help I can get.

Falchion:
I need all the help I can get.

Yeah but not to the extent where you don't learn anything.....

Get one servo working, clenching a finger using sweep as I suggested, with suitable changes for the range of movement and the delay.

Then tie another string to another servo.... change the program to have more than on servo attached and double up the part that does the movement of say myservo1 and myservo2 (or finger1 and thumb or whatever) and get two fingers or knuckles or whatever clenching.

Get each piece working as you go, and save old versions of sketches so you can backtrack to the last version that worked if you make a screwup

I don't understand how to add multiple servos to the breadboard... I read this tutorial (http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html),and I don't get how he added the last 4(?) servos towards the end. I did Sweep on the Arduino UNO, but I don't think there are enough ports on it to support many servos at once. Can I get some help? :frowning:

I did Sweep on the Arduino UNO, but I don't think there are enough ports on it to support many servos at once.

A port consists of 8 pins. It only takes one pin to drive a servo. The UNO has more than enough pins to drive 4 servos.

I don't get how he added the last 4(?) servos

Well you only need one pin per servo for control remember, the power being taken care of off the Arduino. Let's say you have the following lines in your code (extract from sweep):

Servo myservo;

myservo.attach(9);

myservo.write(pos);

You could have this (incomplete code!) for three servos:

Servo myservo;
Servo myotherservo;  // <<<< note new names; you would call these "thumb", "middlefinger" maybe
Servo yetanotherservo;

myservo.attach(9)
myotherservo.attach(10)  // <<<<<<< note the new pin numbers for the yellow / orange control wire
yetanotherservo.attach(11)

myservo.write(pos);

myotherservo.write(pos);

yetanotherservo.write(pos);

So how did you get on yesterday?- Did you get one finger clenching and unclenching?

What is that cord on the battery holder called? I really need one.

No idea

I'm on step 3 of this tutorial (http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html) and the servo doesn't move when I upload the sketch. Can I get some help?

Falchion:
I'm on step 3 of this tutorial (http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html) and the servo doesn't move when I upload the sketch. Can I get some help?

Post your sketch and a picture of your wiring.

// Multi Sweep, Duane B
// Using the servo library created by Michael Margolis
// to control 12 Servos with one Arduino Uno

#include <Servo.h>
// Sample sketch for driving 12 Servos from an Arduino UNO, servos are attached to digital pins 2,3,4,5,6,7,8,9,10,11,12,13

#define CONNECTED_SERVOS 12

// macro just adds two - the first servo is attached to digital pin 2, this gives us upto 12 servos - digital 2 to 13
#define SERVO_TO_PIN(x) (x+2)

Servo myServos[CONNECTED_SERVOS];

#define COUNT_DOWN -1
#define COUNT_UP +1
#define INCREMENT 10 // move in steps of 10 milliseconds

int nPulseWidth = DEFAULT_PULSE_WIDTH ; // 1500, defined in servo.h
int nDirection = COUNT_UP;

volatile unsigned long ulStart = 0;
volatile unsigned long ulStartToEnd = 0;

void setup()
{
// attach the servos
for(int nServo = 0;nServo < CONNECTED_SERVOS;nServo++)
{
myServos[nServo].attach(SERVO_TO_PIN(nServo));
}

// the library sets all servos to 1500 ms pulse width by default, this is center for a steering servo
Serial.begin(9600);
Serial.println("Completed setup");
}

void loop()
{
delay(10); // give the servos time to move after each update

if(ulStartToEnd)
{
Serial.println(ulStartToEnd);
ulStartToEnd = 0;
}

nPulseWidth += nDirection * INCREMENT;

if(nPulseWidth >= 2000)
{
nPulseWidth = 2000;
nDirection = COUNT_DOWN;
}

if(nPulseWidth <= 1000)
{
nPulseWidth = 1000;
nDirection = COUNT_UP;
}

for(int nServo = 0;nServo < CONNECTED_SERVOS;nServo++)
{
myServos[nServo].writeMicroseconds(nPulseWidth);
}
}

Hi-

I can't figure that circuit out from that pic. What's that mishmash of wires on the breadboard?

You need to take a clearer pic- maybe straight down from above?- and also draw a circuit on paper and post that as well.

Here's a test you should do: with the circuit like it is, use the SWEEP sketch. If necessary change the pin number in sweep to match the pin you used for the servo control- looks round about pin 10 or so from that photo?- and compile and upload to Uno.

myservo.attach(9); <<<<<<<<<< make sure this number is correct in sweep

Assuming sweep works, you'll at least know that the servo and the circuit are good. If servo doesn't sweep, and we know the sweep sketch is good, then you can try see what's wrong with the circuit.

Edit.... To make your sketch easier to read, when you post code you should select it all and hit the # button above the :wink: smiley. That formats the code like mine in this post.

Here a close up.

Here a close up.

Still can't make it out, it's very fuzzy and the angle's crap. We're trying to help, but you're not making it easy for us.

Draw the circuit neatly and take a clear pic of that.... You could also use Fritzing to make a pic: advantage of that is that as you do the Fritzing pic it kinda forces you to think about the circuit.

I'm downloading it right now. Sorry for the late replies.

Fritzing will also be useful when you hand the project in. You can print them out and use them in your report, or on your presentation boards or ppt shows.

It's easy to use- there's a library of standard stuff including what you need: breadboard, servos, batteries, wire etc.

But if you're pushed for time, draw the circuit on paper and take a pic of that to post.

Here ya go. Multiple Servo Setup

According to that I think you have the power to the servo back to front.... looks to me like red power to servo black and black power to servo red?

And you have the control on pin 13.... make sure that pin is one of the ones used in the sketch

Well I'll be heading to bed now. Thanks for all the help, and I will start fixing my mistakes tomorrow. XD