The Shape-Shifting Cube Robot
It sits on your shelf looking like an ordinary cube. Press one button, and it unfolds and spins itself into a sphere, a flower, or a star. This guide shows you how to build the whole thing yourself with an Arduino, four small servo motors, and things from a craft store.
Now showing: Cube
A cube that isn't just a cube
This shape-shifting cube robot is one of the most rewarding DIY robotics projects you can build with basic Arduino parts. It hides four small servo motors inside a folding cube shell. When you press the button, the servos pull hinged panels open in a set pattern, so the same cube can "become" a round sphere, a four-petal flower, or a spiky star. It's a great hands-on way for kids and beginner makers to learn about servo motors, circuits, hinges, and simple robot code — while ending up with a toy that's genuinely fun to show off.
What you'll need
Everything here is beginner-friendly and easy to find online or at a craft/electronics store.
Electronics
- 1x Arduino Uno or Nano
- 4x SG90 micro servo motors
- 1x momentary push button
- 1x external 5–6V power supply (4xAA battery pack works great)
- Breadboard and jumper wires
- USB cable for programming
Cube structure
- Foam board or thin plywood (for 6 cube panels)
- Fabric hinge tape or duct tape
- Small cardboard box (the center hub)
- Thin string or fishing line
- Craft sticks (for servo arms/links)
Tools
- Craft knife and ruler
- Hot glue gun
- Scissors
- Small screwdriver
- Pencil for marking
How it actually transforms
The trick isn't magic — it's four hinged panels, each pulled by its own servo motor arm. Change how far and in which direction each arm swings, and the same cube folds into a different silhouette.
Cube (closed)
All four servo arms sit at 0°, holding every panel flat against the hub. It just looks like a plain box.
Sphere
All four arms swing out to the same medium angle, so the panels curl outward evenly in every direction.
Flower
Opposite arms open wider than the side arms, so panels spread out flat like four petals around a center.
Star
Arms alternate between a wide angle and a narrow angle, pushing panels in and out to make sharp points.
Circuit diagram
Four servos draw more current than the Arduino's own 5V pin can safely supply, so we power them from a separate battery pack and share a common ground with the Arduino.
Step-by-step build instructions
Work through these steps in order. Have an adult help with the craft knife and hot glue.
Cut the six cube panels
Cut six equal squares from foam board (about 8cm x 8cm is a good starter size). These will form the outer faces of your cube.
Hinge four of the panels
Pick four panels to be the "moving" ones. Tape one edge of each to the small cardboard hub box using fabric hinge tape, so each panel can swing open and closed freely.
Fix the other two panels
Glue the remaining two panels to the top and bottom of the hub so they stay still — these keep the cube's shape steady while the other four move.
Mount the four servos inside the hub
Glue or screw each servo motor inside the hub box, one facing each hinged panel.
Attach servo horns and arms
Snap a plastic servo horn onto each motor shaft, then glue a craft-stick arm onto the horn.
Link each arm to its panel
Tie a short piece of string or fishing line from the tip of each servo arm to the inside of its matching panel, so turning the servo pulls the panel open.
Wire the push button
Connect one leg of the button to Arduino pin 2, and the other leg to GND.
Wire the servos
Connect each servo's signal wire to pins 3, 5, 6, and 9. Connect all servo power and ground wires to the external battery pack, and tie that ground to the Arduino's GND.
Upload the code
Plug the Arduino into your computer and upload the sketch from the next section using the Arduino IDE.
Test and tune
Press the button and watch the cube move. If a panel doesn't swing far enough, adjust that servo's angle numbers in the code and re-upload.
The code
This sketch moves all four servos smoothly and cycles through four modes each time the button is pressed: Cube → Sphere → Flower → Star → back to Cube.
// Shape-Shifting Cube Robot // Press the button to cycle: Cube -> Sphere -> Flower -> Star #include <Servo.h> Servo servoA, servoB, servoC, servoD; const int pinA = 3, pinB = 5, pinC = 6, pinD = 9; const int buttonPin = 2; int shapeMode = 0; int lastButtonState = HIGH; unsigned long lastDebounce = 0; const unsigned long debounceDelay = 50; void setup() { servoA.attach(pinA); servoB.attach(pinB); servoC.attach(pinC); servoD.attach(pinD); pinMode(buttonPin, INPUT_PULLUP); Serial.begin(9600); goToCube(); // start folded up like a normal cube } void loop() { int reading = digitalRead(buttonPin); if (reading != lastButtonState) { lastDebounce = millis(); } if ((millis() - lastDebounce) > debounceDelay) { if (reading == LOW && lastButtonState == HIGH) { shapeMode = (shapeMode + 1) % 4; changeShape(shapeMode); } } lastButtonState = reading; } void changeShape(int mode) { switch (mode) { case 0: Serial.println("Cube!"); goToCube(); break; case 1: Serial.println("Sphere!"); goToSphere(); break; case 2: Serial.println("Flower!"); goToFlower(); break; case 3: Serial.println("Star!"); goToStar(); break; } } // Smoothly move all four servos toward new target angles void moveAll(int a, int b, int c, int d) { int startA = servoA.read(); int startB = servoB.read(); int startC = servoC.read(); int startD = servoD.read(); int steps = 40; for (int i = 0; i <= steps; i++) { servoA.write(startA + (a - startA) * i / steps); servoB.write(startB + (b - startB) * i / steps); servoC.write(startC + (c - startC) * i / steps); servoD.write(startD + (d - startD) * i / steps); delay(20); } } void goToCube() { moveAll(0, 0, 0, 0); } // panels folded flat void goToSphere() { moveAll(60, 60, 60, 60); } // panels curl out evenly void goToFlower() { moveAll(90, 90, 45, 45); } // panels splay like petals void goToStar() { moveAll(120, 30, 120, 30); } // panels alternate in and out
goTo...() function are just servo angles from 0° to 180°. Change them and re-upload to invent your own shape — a "twist," a "wave," or your own signature pose.⚡ Safety first
- Ask an adult to help with cutting tools and the hot glue gun.
- Always unplug the Arduino before changing any wiring.
- Double-check servo wires are connected the right way round before powering on.
- Keep fingers clear of the panels while testing a new shape for the first time.
Frequently asked questions
Do I need to know how to code already?
No. The code provided is ready to upload as-is. As you get comfortable, you can start changing the servo angle numbers to invent new shapes without needing to learn much new code.
Can I use cardboard instead of foam board?
Yes. Cardboard works fine for a first prototype, though foam board holds its folded shape a little better over time.
Why does it need a separate battery pack for the servos?
Four servos moving at once can pull more current than the Arduino's 5V pin is designed to supply, which can cause the board to reset. A separate battery pack keeps the servos powered reliably and protects the Arduino.
Can I add more shapes?
Yes! Add a new function like goToTwist() with your own four angle values, then add another case to the changeShape() switch and update the modulo number in the main loop.

Comments
Post a Comment