Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Arduinos: Paper Animatronic

Physical Computing, the Internet of Things, Sensors and Servos



  • Learn how to use Servo.h library
  • Learn about the pinMode(), attach(), analogRead(), map(), and write() functions
  • Learn how to make a paper animatronic with two servo motors and a joystick

PaperAnimatronic Code

#include <Servo.h> 
Servo myservoA;  // create servo object to control a servo 
Servo myservoB;
int leftright = A0;
int updown = A1;
void setup() 

  myservoA.attach(3);  // attaches the servo on pin 3 to the servo object 
  pinMode(leftright, INPUT);
  pinMode(updown, INPUT);

void loop() 

  //Read a value - convert from 0..1023 to 10..170 degrees- and send to servo
  int v0 = analogRead(leftright);
  int s0 = map(v0,300,600,10,170);
  //again for the second joystick & servo - go 90 to 170 degrees - we don't want hit the table
int v1 = analogRead(updown);
int s1 = map(v1,0,1023,90,170);

Micro Servos and Joysticks

Micro Servo Wires

The power wire is typically red, and should be connected to the 5V pin on the Arduino board.

The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board.

The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. 

Joystick Pins

GND: Ground

+5V: Power

VRx: x-axis manipulation

VRy: y-axis manipulation

SW: switch (will not be using this pin)

University of Florida Home Page

This page uses Google Analytics - (Google Privacy Policy)

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.