Home > Other >Special Application Circuits > How to Build an Animatronic Eye Using Arduino

How to Build an Animatronic Eye Using Arduino

Source: InternetPublisher:Lemontree Keywords: Arduino DIY design 3D printing Updated: 2024/12/17

In this project we will build an animated eye using Arduino. The idea of ​​making an animated eye came to me while looking for new project ideas online and this project caught my eye immediately. First of all, it looks cool and has a simple mechanism, I learned a lot about mechatronics while doing this project. A big thank you to Will Cogley for building the 3D model and making all the source files accessible to the community, in his words, he wanted to design it so that it would be more accessible to the maker community. There are two versions of this animated eye design, a simple one and an advanced one, for this project we thought of building the simple one, in the process we will tell you about the building experience and the problems we encountered.

Components needed to build a 3D printed animatronic eye

The BOM for this project is very small since all the hard work is done by the 3D printer and we only need some screws and braids, most of which you can find at your local hobby store. A full list of the BOM is given below.

Six SG90 servo motors

Screws M2, M3 and M4

Arduino UNO

Jumper cables

Breadboard

Needle Machine

PLA Filament and 3D Printers

Post-processing and assembly - Animatronic eye mechanism

To work with this project we need to first print all the 3D models, you can find the 3D models in Ikkalebob instructables. After printing all the 3D parts you will need to sand the eyes and some other parts that are required to work smoothly together, once these parts are complete we can move on to the assembly process. If you printed each part correctly your product should look similar to the picture below.

pYYBAGLKMFaAXnc8AAThsAVqw_U153.png

We will start the build by connecting 5 of the 6 servo motors to the Servo_Block module as shown in the image below. To capture the image, I had to use black as the background as it adds a level of detail to the image.

poYBAGLKMEGAetU-AAeUnBKQBCo185.png

Now we attach the Servo_Block to the Main_Base as shown in the image below. We also used four 12mm M3 socket head screws to make the legs of the device.

pYYBAGLKMECAIzHIAAbNPmU2pvQ767.png

Next, we will connect the Eye-Adaptor and Fork for both eyes. After that, we will connect the Eye-Holder with the Eye-Adaptor and the Three-point_Connector with the Fork. After all these processes are completed, it will look like the following image.

pYYBAGLKMDyAOnV2AAW_4NhpUkQ564.png

Once that was done we attached the sixth and final servo to the Sub_Base and then attached the Sub_Base to the Main_Base with screws. After this we popped the PlaceHolder Eye into the Eye Adapter. We also attached the X-Arm and Y-Arm with screws.

poYBAGLKMDWAImZJAAclABb6buA882.png

Now we connect the eyelid connector to the eyelid and we use the M3 screws to fix the eyelid in place from both sides.

pYYBAGLKMDKAFmVdAAbrzxZcfKo911.png

If you have done everything correctly, the image will look like the one shown above, you can see that we have connected all the eyelids with the eyelid connectors and we have tightened them with the arm of the servo motor. Once that is done, we can move onto the coding process.

3D printed Animatronic eye circuit diagram

The schematic diagram of the DIY 3D printed simulated eye is shown below, and you can see that it is very simple and easy to understand. Although the PCA9685 IC, a 16-channel 12-bit PWM servo motor driver, is used in the schematic provided by the project designer and author, we will not be using it in this project because the Arduino servo library can easily handle six servos.

pYYBAGLKMCyAIwsgAAGQuQ8Daas618.png

As we said before, the hardware connections are very simple. We are using six pins of the Arduino to control the six servo motors. If we take a quick look at the specifications of the Arduino, you will see that the Arduino has six PWM pins and we are using all of these pins to control all six servo motors.

Arduino code for controlling the animated eyes

The animated eyes Arduino code is very simple and easy to understand. To make this code work, we will use the Servo.h library of Arduino.

We begin our code by including the required libraries and defining all the instances necessary to control all six servo motors.

#include <servo.h>
servo top_left_eyelid;
servo_bottom_left_eyelid;
servo top_right_eyelid;
servobottom_right_eyelid;
Servo Yarn;
Servo X

Next, we have our setup() function. In the setup function, we have declared which part of the eye goes to which pin on the Arduino. This is very useful because we can unplug all the connectors and connect them as they are.

  top_left_eyelid.attach(10);
  bottom_left_eyelid.attach(11);
  top_right_eyelid.attach(5);
  bottom_right_eyelid.attach(6);
  Yarm.attach(9);
  Xarm.attach(3);

Next we initialize the serial port for debugging and call some functions to keep the eye open and centered, we also add some delay for stability.

  SerialNumber.Start(9600);
  openEyes();
  eyecenter();
  delay(2000);

Next, we have our loop() function, but before we explain the loop function, we are going to explain a few more important functions that are necessary to understand what is going on inside the loop function. These functions are the most important functions, and with these, we will be moving the eyeballs of our system. First, we have the open_eye() function. If you look at the hardware, you need to move one servo clockwise and the other servo counter-clockwise, and we do the same thing for both the left and right eyelids.

void openEye(){
  top_left_eyelid.wri

Next is the close_eye() function, inside the close_eye function we will do the exact same thing as we did in the open_eye function, but in reverse.

void close_eye() {
  top_left_eyelid.write(2);
  bottom_left_eyelid.write(120);
  top_right_eyelid.write(46);
  bottom_right_eyelid.write(55);
}

Next, we have the look_up() and look_down() functions. If you look at the hardware, the Y arm of the mobile device causes the eyeball to move up and down.

void find() {
  Yarm.write(132);
}
void look_down() {
  Yarm.write(45);
}

Next, we have the eye_ball_left() and eye_ball_right() functions, which are identical to the up and down functions, the only difference being the angle of the device.

void eye_ball_left() {
  Xarm.write(50);
}
void eye_ball_right() {
  Xarm.write(130);
}

Next we have the eye_ball_centert() function. In this function we set the X and Y arms to 90 degree angles so that we can move the eye to dead center.

void eye_ball_centert() {
  Xarm.write(90);
  Yarm.write(90);
}

Now we have some other functions that I wrote to make our lives easier. First in that list we have the synchronous_close() function, calling this function will close and open the eye once.

void sync_close() {
  close_eye();
  delay(420);
  openEyes();
  delay(222);
}

Then we have the random_close() function which will randomly open and close the eyes. This will create a cool effect.

void randomClose(){
  close_eye();
  delay(random(220, 880));
  openEyes();
  delay(random(220, 880));
}

Next, we have the random_movement() function. In this function, we use the Arduino's random() function within the delay function to make the eye move randomly.

void randomMovement() {
  Xarm.write(60);
  delay(random(250, 340));
  Yarm.write(80);
  delay(random(250, 340));
  Xarm.write(120);
  delay(random(250, 340));
  Yarm.write(140);
  Xarm.write(60);
  delay(random(250, 340));
  Yarm.write(80);
  delay(random(250, 340));
  Xarm.write(120);
  delay(random(250, 340));
  Yarm.write(140);
  eyecenter();
  delay(300);
  sync.close();
  random.close();
}

Now we will explain the void loop function which is the main function of the Arduino. In this function we will move the eye left, right and center, then up and down, and then we will make the eye blink. We will do this several times and make random movements. Finally, we have two for loops. The for loop is an example of how to achieve smooth motion or moving the eyeball.

void loop(){
  eye_ball_left();
  delay(680);
  eye_ball_right();
  delay(680);
  eyecenter();
  delay(450);
  sync.close();
  eyecenter();
  delay(450);
  look up();
  delay(400);
  lookdown();
  delay(400);
  eyecenter();
  delay(300);
  random.close();
  delay(450);
  look up();
  delay(400);
  lookdown();
  delay(400);
  RandomMovement();
  delay(400);
  eyecenter();
  delay(300);
  top_left_eyelid.write(2);
  bottom_left_eyelid.write(120);
  delay(200);
  top_left_eyelid.write(55);
  bottom_left_eyelid.write(36);
  delay(200);
  openEyes();
  delay(500);
  for (int i = 60; i < 120; i++)
  {
    Xarm.write(i);
    Yarm.write(i - 5);
    delay(10);
  }
  eyecenter();
  delay(400);
  sync.close();
  for (int i = 120; i > 60; i--) {
    Xarm.write(i);
    Yarm.write(i - 5);
    delay(10);
  }
}

This marks the end of the code section and we can move on to the next section of this article.

Testing and debugging 3D printed animatronic eyes

Since the mechanical part of the project was a bit hectic, there were a lot of things that didn't work out when first starting out, so in this section I wanted to cover those topics.

The first problem we encountered was that the eye_place_holders did not move smoothly and there was a lot of friction between the eye_place_holders and the eye_lids.

poYBAGLKMCKAKbGPAAbkhoEa7Bk751.png

The solution to this problem is to lose the screws that hold the eye bracket and the base of the device, these are the labeled screws shown above.

The next problem is how to connect the servo arms to the eye_lid and the arms of the X-arm and Y-arm. This is a big problem because without proper joints the device will not work smoothly, so in the image below you can see a picture of all the servo arms.

poYBAGLKMCKAfbUOAAL7THKBYlw355.png

Code

#include <servo.h>

servo top_left_eyelid;
servo bottom_left_eyelid;
servo top_right_eyelid;
servo bottom_right_eyelid; servo
yarn;
servo xarm;
void setup(){
top_left_eyelid.attach(10);
bottom_left_eyelid.attach(11);
top_right_eyelid.attach(5);
bottom_right_eyelid.attach(6);
yarn.attach(9);
xarm.attach(3);
serial.start(9600);
eye_open();
eyeball_center();
delay(2000);
}
void loop(){
eye_ball_left();
delay(680);
eye_ball_right();
delay(680);
eyeball_center();
delay(450);
sync_close();
// sync close();
eyecenter();
delay(450);
lookup(); delay
(400);
lookdown();
delay(400);
eyecenter();
delay(300);
randomclose() ;
delay(450);
lookup();
delay(400); lookdown
();
delay(400);
randommove();
delay(400);
eyecenter();
delay(300);
top_left_eyelid.write(2);
bottom_left_eyelid.write(120);
delay(200);
top_left_eyelid.write(55);
bottom_left_eyelid.write(36);
delay(200);
eyeopen();
delay(500);
for (int i = 60; i < 120; i++)
{
Xarm.write(i);
Yarm.write(i - 5);
delay(10);
}
eyecenter();
delay(400);
sync close();
for (int i = 120; i > 60; i--) {
Xarm.write(i);
Yarm.write(i - 5);
delay(10);
}
}
void randomMove() {
Xarm.write(60);
delay(random(250, 340));
Yarm.write(80);
delay(random(250, 340));
Xarm.write(120);
delay(random(250, 340));
Yarm.write(140);
Xarm.write(60);
delay(random(250, 340));
Yarm.write(80);
delay(random(250, 340));
Xarm.write(120);
delay(random(250, 340));
Yarm.write(140);
eyeCenter();
delay(300);
syncClose();
randomClose();
}
void randomClose() {
close_eye();
delay(random(220, 880));
openeye();
delay(random(220, 880));
}
void sync_close() {
close_eye();
delay(420);
openeye();
delay(222);
} void
eye_ball_left() {
Xarm.write(50);
} void eye_ball_right() { Xarm.write(130); } void eye_ball_centert() { Xarm.write(90); Yarm.write(90); } void lookup() { Yarm.write(132); } void look_down() {











Yarm.write(45);
}
void close_eye() {
top_left_eyelid.write(2);
bottom_left_eyelid.write(120);
top_right_eyelid.write(46);
bottom_right_eyelid.write(55);
} void
close_eye() {
top_left_eyelid. write(55);
bottom_left_eyelid.write(36);
top_right_eyelid.write(2);
bottom_right_eyelid.write(160);
}

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号