Arduino Crane

There are a lot of fun ways to build cranes. For this project we used:

  • 1 – Arduino Mega (Uno or equivalent could also be used).
  • 1 – generic motor/servo shield
  • 1 – breadboard
  • 1 – Webcam mount (with 2 servos)
  • 4 buttons and 4 resistors (10KΩ  whatever you have).
  • jumpers
  • K’Nex pieces
  • String or wire to support the servos to the structure

We used string and wire to secure the Webcam mount to our structure.


For the servos that we used we found that they had “jitter” if they were connected directly to the Arduino. Depending on the servos that you use you may or may not experience “jitter”. To remove “jitter”  a motor/servo shield can be used, these shields have from filtering to remove  noise on the power and data pins to the servos.

There is no difference in the Arduino code if you are or are not using a servo shield. Typically a servo shield will use data pins 9 and 10.

For this project we used 4 buttons to control the 2 servos. The circuit that we used is shown below.


The code is:

// 4 button crane project

Servo servo1;
Servo servo2;

char thecmd;
int xpos = 90;
int ypos = 90;

int uPin = 31;
int dPin = 33;
int lPin = 35;
int rPin = 37;

void setup() {
Serial.println("Crane Controls");
Serial.println("Push a button to control...");
servo1.attach(9); // attaches the servo on pin 9 to the servo object
servo2.attach(10); // attaches the servo on pin 9 to the servo object

servo1.write(xpos); // left and right servo
servo2.write(ypos); //up and down servo

pinMode(uPin, INPUT);
pinMode(dPin, INPUT);
//pinMode(rPin, INPUT);
//pinMode(lPin, INPUT);
void loop() {

if (digitalRead(uPin) == HIGH) { move_crane(servo2, 5); }
if (digitalRead(dPin) == HIGH) { move_crane(servo2, -5); }
if (digitalRead(lPin) == HIGH) { move_crane(servo1, 5); }
if (digitalRead(rPin) == HIGH) { move_crane(servo1, -5); }

void move_crane(Servo theservo, int direction) {
Serial.println("Button pushed");
int minpos = 50;
int maxpos = 220;
if (direction  minpos) {
ypos = ypos + direction;
else {
if (ypos < maxpos) {
ypos = ypos + direction;

2 thoughts on “Arduino Crane

Leave a Reply to Pete Metcalfe Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s