Accelerometer Controlled Animatronic Finger

Updated 28 April 2022

This project incorporates two Arduino boards, in a Master/Slave setup. The master is one with an accelerometer (ADLX345) and the slave has a Servo attached (SG90). When tilting the accelerometer, the master Arduino tells the Slave Arduino to rotate the servo. This is a great way to learn slave and master serial communication. 

Parts you'll need:

Step 1 - Wiring:

Wire the ADLX345 to Master Arduino, the Servo to the slave Arduino, using the wiring diagrams below. Note that some servos are brown, red and orange wiring. (Negative, Positive, Signal). Then connect the Arduino's to each other and make any other connections as below. 

motion-controlled-animatronic-finger-circuit-diagram

Step 2 - Make it:

Attach Slave Arduino & Servo to a board, then make you 'finger' by threading some string through a straw, and taping it at the end. Next, make a half cut in the straw so that when the string is pulled, the top end of the straw raises. Hot Glue this to the board to hold it steady. Excuse the hot glue wisps and tails! I'm going for a low-pro setup.

motion-controlled-animatronic-finger-hardware-setup

Step 3 - Code it:

The code that I used for this project was written by Nicholas Zambetti and appeared in the examples for the Wire library - Upload Master.ino to the master Arduino.

 
// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library // Receives data as an I2C/TWI slave device // Refer to the "Wire Master Writer" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include <Wire.h> #include <Servo.h> Servo myservo; void setup() { Wire.begin(8); // join i2c bus with address #8 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output myservo.attach(9); } void loop() { delay(100); } // function that executes whenever data is received from master // this function is registered as an event, see setup() void receiveEvent(int howMany) { while (1 < Wire.available()) { // loop through all but the last char c = Wire.read(); // receive byte as a character Serial.print(c); // print the character } int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer myservo.write(x); }

Upload Slave.ino to the slave Arduino;

 
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this

// Created 29 March 2006

// This example code is in the public domain.


#include <Wire.h>

void setup() {
  Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop() {
  serial(x);
  delay(1000);
  x = x + 20;
}

void serial(byte x) {
  Wire.beginTransmission(8); // transmit to device #8
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte
  Wire.endTransmission();    // stop transmitting
}

The code works by the Master Arduino processing the accelerometer info, and sending a "rotation amount"' to the slave, which would servo.write(rotation amount). You can see the effect this has down below! 

Attachment - Project Files

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.