Arduino and several steppers and servo's

So i'm just getting started with the arduino. I'm doing pretty well with it. I have 2 stepper motors running (forgot to mention it's with 2 easydriver 4.2) with 1 servo(via pwm pin and servo library). I'm in need to set up 4 steppers, with 4 servo's. Imagine a cuckoo clock that goes crazy. the second hand functions normally, ticking, and the pendulum sways in time., but suddenly it starts to spin wildly and randomly, with the pendulum swaying faster than normal. now multiply this by 4!
4 steppers, 8 servo's.
The stepper controls the second hand, one servo is the pendulum and the other the cuckoo. So 1 stepper, and 2 servo's per cuckoo clock.

questions i have:

  1. can one arduino control all this?
  2. i can control the steppers and the servo at the same time only by writing out individual actions, it takes a lot of typing. with various codes i tried, the stepper runs random, then the servo moves, then stepper, then servo. what i need is it to go all at once. servo moves side to side in continuous movement, then speeds up. How to make it run this, while stepper moves?
  3. i used a push button to step through the action. push once, starts regular tick tock action of stepper and servo. push 2nd time, all goes crazy, push 3rd, it stops. problem is it doesn't stop, or it takes repeated presses to get it to stop, and then it will only stop once the loop is done. seems that the button presses are only looked at once the loops are finished. I used the ladyada tutorial #5 "button modes" code. works with blinky led's but not so well with motors and loops.
    Thanks for any input.
  1. Yes.

  2. Write your code like the blink without delay example in the learning section. You implement what is known as a state machine.

it takes a lot of typing.

If there is a lot of typing you are doing it wrong, especially if the typing produces lines that are repetitive or very similar.

  1. Again use a state machine like structure to your code.

can one arduino control all this?

That depends on what the meaning of "this" is :slight_smile:

Are all 4 of these clocks supposed to move exactly in sync? I.e., can you drive two sets of 4 servos with two PWM outputs? Or do they need to move differently?

Well i have been busy, and i have worked out that yes the arduino can control 4 steppers and 6 servo's. the code is clumsy because i'm new at this.
The only problem i'm having is trying to make the button work so that it skips through 3 motor modes. ticking normal, ticking crazy, and off. the 1st 2 modes work via the button press. but turning it all off is not working other than hitting the reset switch. i'm looking into interrupts but i just can't work it out. how do i do an interrupt so that i can select 3 different modes.

how do i do an interrupt so that i can select 3 different modes.

If you're able to select two of the three desired modes with the button, but not the third, an interrupt is not going to help.

Posting your code, no matter how ugly, will.