Project showcase

Animatronic Tail by Circuito.io © GPL3+

Our first wearable project (!) is an animatronic tail with dual-control. No animals harmed in the making of this project.

  • 4,525 views
  • 4 comments
  • 18 respects

Components and supplies

Necessary tools and machines

3drag
3D Printer (generic)

Apps and online services

About this project

Introduction

Welcome to our first wearable project!

You may be wondering why we decided to make this project. Well…first of all, it’s cool! But actually, this tail was designed to be part of a live stage performance that we were asked to assist with, so we took on the challenge. We’re pretty happy with the results.

Animatronic Tail by circuito.io

Animatronics is the imitation of animal or human movement, and it can be done in several ways. In this case, we decided to use an MPU 6050 and servo motors. The MPU 6050 is a small sensor has a triple axis accelerometer and gyro combined, allowing very deep motion detection and analysis.

We placed three servos on the tail, which allowed it to move in a close-to-natural way: once one servo pulls the other releases tension and vice versa. The top servo allows the up and down movement. We also added an option to toggle between the MPU and a joystick, through the joystick’s push-button, so you can also manually control the tail's movement.

Setting up the circuit

Here’s a magic link to circuito.io which shows all the components you need for the project. Notice that the battery is 9V, but eventually you will need to use a 12v battery or 8 AA batteries.

If you would like to replicate the project we made exactly, click generate.

Modifications

You can also make some adjustments to the circuit: for example you can add addressable LEDs to light up the tail, or maybe you want to use a more compact Arduino such us Arduino Micro or Pro-Mini. Another option is adding Bluetooth control or WiFi connectivity.

Bill of Materials and Code

After clicking “Generate” and “Open my circuito”, you’ll see three sections in the circuito.io Reply: BoM (Bill of materials), step-by-step wiring guide, and code.

  • Going through the BoM, make sure that you have all the parts you need. Notice that there are also peripherals such as capacitors and jumper cables, that are necessary for your project.
  • Next, follow the step-by-step wiring guide which will show you exactly how to put together your circuit.
  • Last, in the code section, you'll see a sample code for your circuit. This code is not specific for the tail project, but rather it is a sample code that activates the different components in your circuit.

Activate Code

To activate the code, follow these steps:

  • Download the code
  • Extract it to your computer
  • Open with Arduino IDE
  • Upload to your Arduino

If everything works properly, replace the sample code you received from circuito.io with the code in this tutorial. Make sure to leave the //Include Libraries and //Pin Definitions at the top of the code, and also keep all the libraries that you received from the circuito reply.

Building the Tail

The 3d designs, laser cuts, materials and assembly guide are on Thingiverse.

Code

Animatronic Tail CodeArduino
Replace the code you received from circuito.io reply with the code below. Keep the // Include Libraries and
// Pin Definitions from the original code.
// Global variables and defines
int16_t mpu6050Ax, mpu6050Ay, mpu6050Az;
int16_t mpu6050Gx, mpu6050Gy, mpu6050Gz;

int posx = 0;
int posy = 0;

int joystickX;
int joystickY;

int joystickX_Cal = 0;
int joystickY_Cal = 0;
//use button to toggle between sensors
bool sensor_state = 1;

Servo servoUP;  // create servo object to control a servo
Servo servoLEFT;  // create servo object to control a servo
Servo servoRIGHT;  // create servo object to control a servo

MPU6050 mpu6050;
Joystick joystick(JOYSTICK_PIN_VRX, JOYSTICK_PIN_VRY, JOYSTICK_PIN_SW);


/* This code sets up the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. */
void setup() {
  // Setup Serial which is useful for debugging
  // Use the Serial Monitor to view printed messages
  Serial.begin(9600);
  while (!Serial) ; // wait for serial port to connect. Needed for native USB
  Serial.println("start");

  Wire.begin();
  mpu6050.initialize();

  servoUP.attach(SERVO_1_PIN_SIG);  // attaches the servo on pin 9 to the servo object
  servoLEFT.attach(SERVO_2_PIN_SIG);  // attaches the servo on pin 9 to the servo object
  servoRIGHT.attach(SERVO_3_PIN_SIG);  // attaches the servo on pin 9 to the servo object

  // Read Joystick X,Y axis and press
  joystickX_Cal =  joystick.getX();
  joystickY_Cal =  joystick.getY();
  joystickX = joystickX_Cal;
  joystickY = joystickY_Cal;
}

/* This code is the main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. */
void loop() {
  int joystickSW =  joystick.getSWonPress();
  if (joystickSW)
  {
    sensor_state = !sensor_state;
    //Serial.println("Switch sesnor");
  }

  if (sensor_state)
  {

    joystickX +=  (joystick.getX() - joystickX_Cal);
    joystickY +=  (joystick.getY() - joystickY_Cal);

    joystickX = constrain(joystickX, 0, 1023);
    joystickY = constrain(joystickY, 0, 1023);
    
 /* Serial.print(joystickX);
    Serial.print("\t");
    Serial.println(joystickY);*/
    
    posx = map(joystickX, 0, 1023, 0, 180);
    posy = map(joystickY, 0, 1023, 0, 180);
    
     /*   Serial.print(posx);
        Serial.print("\t");
        Serial.println(posy);*/
    
    servoLEFT.write(posx);              
    servoRIGHT.write(posx);              
    servoUP.write(posy);
  }
  else
  {
    mpu6050.getMotion6(&mpu6050Ax, &mpu6050Ay, &mpu6050Az, &mpu6050Gx, &mpu6050Gy, &mpu6050Gz);   //read accelerometer and gyroscope raw data in three axes
    posy = constrain(map(mpu6050Gx, -16000, 16000, 0, 180), 0, 180);
    posx = constrain(map(mpu6050Gy, -16000, 16000, 0, 180), 0, 180);

    //Serial.print(mpu6050Gy);
/*
    Serial.print(posy);
    Serial.print("\t");
    Serial.println(posx);*/

    //If leaning forward rise up tail
    if (posx < 80)
      servoUP.write(175);
    //If leaning back lower the tail
    else if (posx > 100)
      servoUP.write(5);

    if (posy > 110)
    {
      servoLEFT.write(175);              // tell servo to go to position in variable 'pos'
      servoRIGHT.write(175);              // tell servo to go to position in variable 'pos'

    }
    else if (posy <= 70)
    {
      servoLEFT.write(5);              // tell servo to go to position in variable 'pos'
      servoRIGHT.write(5);              // tell servo to go to position in variable 'pos'

    }
  }




  delay(100);

}

Custom parts and enclosures

3D designs and laser cuts for Animatronic Tail
In the link you'll find all the design files you need for the tail including explanations and materials.

Comments

Similar projects you might like

Animatronic Hand

Project showcase by Team Nuts and Bolts

  • 1,152 views
  • 0 comments
  • 4 respects

Giftduino - The Perfect Arduino Gift Box

Project tutorial by circuito.io team

  • 13,086 views
  • 3 comments
  • 30 respects

Full Animatronic Sorting Hat With Custom Software -$22

Project tutorial by jegatheesan

  • 10,198 views
  • 11 comments
  • 80 respects

Running Breadboard

Project showcase by circuito.io team

  • 2,290 views
  • 1 comment
  • 14 respects

Robotic Arm from Recycled Materials

Project tutorial by circuito.io team

  • 24,732 views
  • 23 comments
  • 97 respects

Intelligent Door Lock

Project in progress by Md. Khairul Alam

  • 15,963 views
  • 19 comments
  • 95 respects
Add projectSign up / Login