So, I'm fairly new to much of Arduino, but slowly learning. Costuming is my main hobby, and I wondered if it was possible to use a single Arduino Uno to control two servos, one to make a set of eyes blink, and another to make a mouth open and close (a second blinking mechanism). It's for a prop plushie/puppet.
I have two servos and my Arduino in front of me, and I received a Sparkfun Inventors Kit a while ago for a present. I know the code I want to use for each servo, but since I want them to move independent of each other, I am stumped (I would like the eyes to close and open every 500/3500 ms and the mouth to open and close on a 1000/5000 ms cycle).
I searched through various topics, but I think what I want to do is either infeasible (I don't see how, but I admit it possible that I am asking too much of the Arduino) or so simple that the solution is getting bogged down in all the extra things people have in the example codes, and I don't know what I need, what I don't, and what the lines of code are doing.
The code I'd like to use for both seems simple, and was based off of the examples I could find (especially the SIK example), but both servos just synced up, with one running through the 500/3500 blink, and the other then running through the 1000/5000 blink, then back to the first, instead of each going through its own loop regardless of what the other was doing. I really don't want them synced. Is this possible, or must they be synced with each other?
Below was my best attempt, which gave me the above result.
Code start
#include <Servo.h>
Servo servoeyes;
Servo servomouth;
void setup()
{
servoeyes.attach(9);
servomouth.attach(10);
}
void loop()
{
int position;
servoeyes.write(90);
delay(500);
servoeyes.write(180);
delay(3500);
servomouth.write(90);
delay(1000);
servomouth.write(180);
delay(5000);
}
Code end
I tried changing the delay parts to servoeyes.delay and servomouth.delay, but the verify nixed that idea, and an hour of searching only gave me a headache and a need to seek out help on this forum.
Thank you for any help you can provide. Coding languages are not my forte, and I don't need a great deal of explanation, just some basic pointers for a newbie trying out Arduino.