DIY Mechanical Piano Art Robot

DIY Mechanical Piano Art Robot: A Fun Music Robotics Project for Kids
🤖 Robotics Project · Ages 11+

Build a Mechanical Piano Art Robot!

Little robot fingers press the keys, a string of LEDs lights up in time with every note, and a screen shows what's playing — music and light working together, built by you.

⏱️ A weekend project 🧩 Intermediate 🎵 8 keys 👨‍👩‍👧 Adult help needed for wiring

🧰 What You'll Need

Gather these parts before you start — most are common hobby-electronics components.

🔷

Arduino Uno (1x)

The brain that plays the song and controls everything.

🦾

SG90 micro servos (8x)

One per key — each presses a single note.

🎹

Small keyboard or 8 key levers

A toy keyboard works great, or build simple lever keys yourself.

💡

WS2812 addressable LED strip (8+ pixels)

Lights up in sync with the notes being played.

📟

16x2 I2C LCD

Displays the name of the song that's playing.

🔊

Small piezo buzzer

Plays the actual musical notes.

🔘

Push button (1x)

Starts the performance.

🔋

5–6V external power supply

Powers all 8 servos without overloading the Arduino.

🪵

Wooden frame or box

Holds the servos above the keys, like the model in the photo.

⚙️ How Does It Work?

Each of the 8 keys has its own tiny servo motor perched above it. When the Arduino wants to play a note, it tells that key's servo to swing its little arm down, tap the key, and lift back up — just like a finger.

At the very same moment, the matching LED on the strip lights up in colour, and the buzzer sounds the note's pitch. Because all three things — the key press, the light, and the sound — are triggered together in the code, the light show always stays perfectly in time with the music.

The LCD screen simply displays the name of the song, so anyone watching knows exactly what the robot is performing.

LED lights up Servo presses key

🔌 The Circuit Diagram

Servos have their own built-in driver, so each one connects straight to an Arduino pin — no extra motor driver board needed.

Arduino Uno USB 8 signal pins → servos 8x Micro Servos one per piano key (pins 2–9) WS2812 LED Strip data pin, lights up per note 16x2 LCD I2C, song name Buzzer plays each note Push Button starts the song 5–6V Power Supply powers all 8 servos ground shared with the Arduino's GND
ConnectionGoes toNotes
Arduino digital pins 2–9Signal wire of each of the 8 servosOne pin per key servo
External 5–6V supplyAll servo power (+) wiresKeeps the Arduino's own 5V rail free
Supply GNDArduino GNDCommon ground — required for signals to work
Arduino pin 10WS2812 LED strip data-inAdd a 300–500Ω resistor on the data line if flickery
Arduino A4 / A5LCD SDA / SCLStandard I2C connection
Arduino pin 11Buzzer (+)Plays each note's pitch
Arduino pin 12Push buttonUse `INPUT_PULLUP`, button to GND

🛠️ Let's Build It — Step by Step

Prepare the keyboard

Use a small toy keyboard, or build 8 simple lever "keys" from craft sticks that can be pressed down.

Mount the servos

Fix a servo above each key so its horn arm can swing down and tap the key when it turns.

Wire the servos

Connect each servo's signal wire to its own Arduino pin, and power all eight from the external 5–6V supply with a shared ground.

Attach the LED strip

Mount the WS2812 strip where it's easy to see, and connect its data pin, 5V, and ground.

Add the LCD, buzzer, and button

Wire the LCD over I2C, the buzzer to a digital pin, and the push button with a pull-up resistor.

Upload the code

Flash the sketch from the next section using the Arduino IDE, with the required libraries installed.

Calibrate each key

Test one servo at a time and adjust its press angle until it taps its key firmly but gently.

Press play!

Push the button and watch your robot perform — keys pressing, lights dancing, and music playing all together.

💻 Time to Code!

This sketch moves each key's servo, lights its matching LED, and sounds its note — all at once, in time with the song.

Install the Servo, Adafruit NeoPixel, and LiquidCrystal I2C libraries from the Library Manager, then upload this sketch to your Arduino Uno.

// Mechanical Piano Art Robot
// Presses keys with servos, lights LEDs, and plays notes together

#include <Servo.h>
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define NUM_KEYS 8
#define LED_PIN 10
#define BUZZER_PIN 11
#define BUTTON_PIN 12

Servo keyServo[NUM_KEYS];
const int servoPins[NUM_KEYS] = {2,3,4,5,6,7,8,9};

Adafruit_NeoPixel strip(NUM_KEYS, LED_PIN, NEO_GRB + NEO_KHZ800);
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int restAngle  = 90;   // key resting position
const int pressAngle = 60;   // key pressed position

const int noteFreq[NUM_KEYS] = {262,294,330,349,392,440,494,523}; // C4–C5

// Which key to press, and how long each note lasts (ms)
struct Note { int key; int duration; };
Note song[] = {
  {0,400},{0,400},{4,400},{4,400},
  {5,400},{5,400},{4,800},
  {3,400},{3,400},{2,400},{2,400},
  {1,400},{1,400},{0,800}
};
const int songLength = sizeof(song) / sizeof(song[0]);

void setup() {
  for (int i = 0; i < NUM_KEYS; i++) {
    keyServo[i].attach(servoPins[i]);
    keyServo[i].write(restAngle);
  }
  strip.begin();
  strip.show();

  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Press button");
  lcd.setCursor(0, 1);
  lcd.print("to play song");

  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {
  if (digitalRead(BUTTON_PIN) == LOW) {
    playSong();
  }
}

void playSong() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Now Playing:");
  lcd.setCursor(0, 1);
  lcd.print("Twinkle Star");

  for (int i = 0; i < songLength; i++) {
    playNote(song[i].key, song[i].duration);
  }

  strip.clear();
  strip.show();
}

void playNote(int key, int duration) {
  tone(BUZZER_PIN, noteFreq[key], duration);   // sound the note

  strip.clear();
  strip.setPixelColor(key, strip.Color(0, 150, 255));  // light the matching LED
  strip.show();

  keyServo[key].write(pressAngle);  // press the key
  delay(duration);
  keyServo[key].write(restAngle);   // release the key
  delay(50);
}
Tip: Servos already have a built-in driver, so no L298N or other motor driver is needed — just wire each signal pin straight to the Arduino.
Tip: Adjust pressAngle in small steps until each key is tapped firmly without straining the servo.
Challenge: Add a second song array and let the button choose between songs each time it's pressed.

🛡️ Safety First

⚠️

Keep it safe while you build and perform:

  • Ask an adult to help with wiring and setting up the power supply.
  • Keep fingers away from the keys while the robot is playing — the servo arms move quickly.
  • Use a power supply sized for 8 servos, and never let the LED strip or servos share power with the Arduino's own 5V pin.
  • Always connect the external supply's ground to the Arduino's ground.
  • Turn off power before changing any wiring or servo mounting.

✨ Fun Piano Facts

A little history to enjoy while your robot performs.

🎼

Self-playing "player pianos" that used punched paper rolls were popular over a century ago.

🎨

Turning sound into light is called audio-visualisation, and artists use it in concerts worldwide.

🎹

A full-size piano has 88 keys — your 8-key robot plays one octave of notes.

🤖

Robots that make music sit at the crossroads of engineering, coding, and art.

❓ Frequently Asked Questions

How does a mechanical piano robot press its own keys?

A small servo motor sits above each key. When the Arduino sends it a command, it swings an arm down to press the key, then lifts back up — just like a tiny mechanical finger.

Do I need a motor driver board for the servos?

No. Hobby servos have their own built-in driver and only need a signal wire connected directly to the Arduino, plus power and ground. A board like an L298N is only needed for plain DC motors, not servos.

What makes the LEDs match the music?

Every time the code presses a key, it lights the matching LED at the same moment, so the light pattern always stays in sync with the notes.

Is this project safe for kids to build?

Yes, with adult supervision for wiring and the power supply. Fingers should stay clear of the keys while the robot is playing.

🎹
Made with ♥ for young makers. Share what your robot plays with #PianoArtLab!

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
★★★★★ Young inventors love it!
🖨️
3D Print
All parts
⚡
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 ₹300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
★★★★★ Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 ₹200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course