How to create a pre-programmed route for servos

Hi folks,

I'm about to build a Mearm (http://mearm.com/) which is my first project with arduino (or with anything that includes coding really).

It has four small servo motors which I'm going to be controlling with potentiometers. But I would also like to create pre-programmed routes for it (which mearm would run automatically). Can you guys advice me or link me to a guide which shows how to to do this.

Any would be much appreciated.

But I would also like to create pre-programmed routes for it

What do you mean by "pre-programmed routes"? Is that going to be a series of new positions for each of the 4 servos? Where is the data going to be stored? How is the data going to be stored?

PaulS:
What do you mean by "pre-programmed routes"? Is that going to be a series of new positions for each of the 4 servos?

Yes, something like this:

  1. All servos except the gripper's move -> Mearm gets close to an object
  2. Gripper's servo moves -> Me arm's gripper graps the object
  3. Three other servos move -> Mearm gets another position
  4. Gripper's servo moves -> Mearm drops the object.

PaulS:
Where is the data going to be stored?

I guess in an arduino sketch.

PaulS:
How is the data going to be stored?

That's the question I'm asking Paul :slight_smile:

You could use an array, EEPROM or maybe a file on an SD card depending on your requirements.

That's the question I'm asking Paul

Then the answer is any way that you like. You get to define how the data is stored.

Of course, you need to consider what data needs to be stored. Are the servo positions sufficient? If so, how will the Arduino know how long to hold in any given configuration? Or, should it simply slam through the set up positions as fast as it can?

PaulS:
Then the answer is any way that you like. You get to define how the data is stored.

Of course, you need to consider what data needs to be stored. Are the servo positions sufficient? If so, how will the Arduino know how long to hold in any given configuration? Or, should it simply slam through the set up positions as fast as it can?

It shouldn't just go through everything at max speed. Do I just use delays between the movements? Also it would be nice to control the speed of individual servo's speeds.

Do I just use delays between the movements?

That's one way. The blink without delay example shows another.

Also it would be nice to control the speed of individual servo's speeds.

Longer or shorter delays between steps does that.

If you want to control the time for each step you will need to record both the time interval and the position.

The demo Several Things at a Time illustrates how to use millis() to manage timing - it is an extended example of BWoD.

It also includes code for moving a servo in small steps at intervals.

...R