I'm new to the arduino world, and have always been fascinated by animatronics. I want to create the classic animatronic eye using my arduino uno and some servos. I think I've come up with an effective sketch, but I want to add a 3rd servo for a blinking eyelid (I'm currently using 2 for up/down and left/right movement). I'm shooting for random movement from the servos, to make the eye movement appear lifelike/natural, it'd be great if the blink did the same but right now it's no biggie. Any help or guidance is greatly appreciated! I've added my sketch below:
#include <Servo.h>
Servo horservo; //servo for left & right movement
Servo vertservo; //servo for up & down movement
byte randomhor; //define random horizontal position variable
byte randomvert; //define random verticle position variable
int randomdelay; //define random delay variable
#define HLEFTLIMIT 0 //deine left limit on the horizontal servo
#define HRIGHTLIMIT 180 //define right limit on the horizontal servo
#define VBOTTOMLIMIT 180 //define bottom limit on the verticle servo
#define VTOPLIMIT 0 //define top limit on the verticle servo
void setup() {
horservo.attach(7); //attach servo to pin 7
vertservo.attach(9); //attach servo to pin 9
randomSeed(analogRead(0)); //create some random values using an unconnected analog pin
}
void loop() {
randomhor = random(HLEFTLIMIT, HRIGHTLIMIT); //set limits for horizontal servo
randomvert = random(VTOPLIMIT, VBOTTOMLIMIT); //set limits for vertval servo
delay(randomdelay); //delay for random amount of time (time length set above)
}
Eye_Full_Servo_Test.ino (1.2 KB)