For my first major project using the Arduino Mega 2560 I plan to create an animatronic face using 12-20 servos. Currently I'm working on starting to write out the code, and I'm wondering if you guys have any tips for me. Also, if you are experienced with Arduino and willing to help me out, I would appreciate you contacting me at my email Th30ry0fm1nd@gmail.com. Thank you for your support.
Make sure you have a good power supply for the servos, they can draw an amp when moving a load. Post a link to the spec for yours.
www.hobbyking.com has servos in different sizes.
Connect all the grounds together.
Use blink without delay style code so you can have several servos moving at once and be waiting for each to finish moving before starting the next.
Use an MP3 module(s) to play sounds as needed.
MDFLY - Search Results for "mp3"
Send simple serial message to start a file playing, or stop it, or pause it, or continue it.
CrossRoads:
Make sure you have a good power supply for the servos, they can draw an amp when moving a load. Post a link to the spec for yours.
www.hobbyking.com has servos in different sizes.
Connect all the grounds together.
Use blink without delay style code so you can have several servos moving at once and be waiting for each to finish moving before starting the next.
Use an MP3 module(s) to play sounds as needed.
MDFLY - Search Results for "mp3"
Send simple serial message to start a file playing, or stop it, or pause it, or continue it.
Thank you very much!
Just to add to what CrossRoads said, on the Blink Without Delay style code, since you probably don't get the significance of that right now....
Have a look at these two examples: Blink and Blink Without Delay and you'll see the problem with using delay(). It literally does exactly that: it delays the rest of your program. It's known as blocking.
So if, for example, you needed some user input (perhaps a push button, or a sensor which detects someone coming close so that the music starts) that input will not be seen by Arduino if you're sitting in a delay. The without delay approach means that the Arduino can monitor inputs- eg look for a button to be pressed- while it's servicing the other stuff. Even a relatively small processor chip like Arduinos use is easily powerful enough to leap around and monitor loads of inputs and manage outputs, provided you don't let it block itself.
Can't be emphasised too much in your case: to manage a dozen or more servos is not going to be a trivial task, and you would be well advised to go the without delay route right out the blocks. It's easily scaleable.
You may find this video of use.
I work in animatronics.
Recent project (facial motion capture in openCV driving an animatronic face) was using digital servos and I wanted greater than 50Hz PWM (as my facial mobcap was at 120Hz) - that meant the mega could only run 8 servos concurrently (with a tweak of the servo library) - running 16 meant two serial streams, ended up being problematic/glitchy ...
Solution, Polulu USB servo driver.
No more hassle. (except power as the others have pointed out)
If you're happy with 50Hz then this is less of a hassle - as will be the baud rate bottleneck.
How do you plan on controlling the face? scripts? played from where? real time control via something like a PS controller? via PC or direct to the arduino? what sort of update rate? is there a latency concern?