Build it step by step
0 of 7 doneTest a servo
Move it to 60, 90 and 120 degrees.
Mount on the headband
Fix both with foam and zip ties.
Write the poses
Happy, curious, sleepy.
Add the button
Cycle moods.
Add the sound sensor
Startle on a clap.
Add the battery
Fit the LiPo in a pouch.
Cover moving parts
Foam over horns and gaps.
How do you build a moving cat ears headband?
Two servos move cat ears on a headband to match a mood picked with a button or triggered by sound. You need Seeed XIAO RP2040, SG90 Micro Servo × 2, Sound sensor module (KY-038), Tactile push button 6 mm and Li-Po battery 3.7 V 1000 mAh. It takes 7 steps and about 120 minutes.
- Level
- Beginner
- Time
- About 120 min
- Parts
- 5
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Left servo signal | XIAO D0 | Left ear |
| Right servo signal | XIAO D1 | Right ear |
| Servos plus and minus | LiPo plus (through the XIAO BAT pads) and GND | Servo power (small 9 g servos work on 3.7 V) |
| Sound module VCC and GND | XIAO 3V3 and GND | Power |
| Sound module AO | XIAO D2 (analog) | Loudness |
| Button | XIAO D3 and GND | Next mood |
| LiPo | XIAO BAT pads | Power and charging |
Code
Two small servos move the ears in small steps, so they stay gentle. The moods are short animations picked with the button, and a loud sound makes both ears perk up for a moment. Use two 9 g micro servos on a light headband, keep every moving part away from hair, ears and eyes, and cover the servo horns with soft foam so nothing can pinch. The servos draw current in short bursts, so powering them straight from a LiPo (3.7 V) works for micro servos but they move slowly; do not use stronger servos. Use a protected LiPo, tuck it in a pouch and never wear the headband while it charges. Take it off if anything feels uncomfortable, and supervise young children. Sound sensitivity is set by the module's small screw. Arduino IDE with the Raspberry Pi Pico/RP2040 boards package by Earle Philhower, board "Seeed XIAO RP2040".
Runs on a virtual Seeed XIAO RP2040 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Cat ears: moods and a startle on loud sound. Board: Seeed XIAO RP2040. Library: Servo (built into the RP2040 core).
#include <Servo.h>
Servo L, R;
const int SND = D2, BTN = D3;
int mood = 0; unsigned long lastBtn = 0, lastTwitch = 0;
void pose(int l, int r, int ms) { // move gently to a pose in small steps
int cl = L.read(), cr = R.read();
for (int i = 1; i <= 20; i++) { L.write(cl + (l - cl) * i / 20); R.write(cr + (r - cr) * i / 20); delay(ms / 20); }
}
void setup() {
L.attach(D0); R.attach(D1);
pinMode(BTN, INPUT_PULLUP);
L.write(90); R.write(90);
}
void loop() {
if (!digitalRead(BTN) && millis() - lastBtn > 300) { mood = (mood + 1) % 3; lastBtn = millis(); }
if (analogRead(SND) > 800) { // a loud noise: perk both ears up quickly
pose(130, 50, 200); delay(600); pose(90, 90, 400);
}
switch (mood) {
case 0: // happy: ears perk up and down together
pose(120, 60, 500); pose(90, 90, 500); break;
case 1: // curious: one ear at a time
pose(120, 90, 400); delay(300); pose(90, 60, 400); delay(300); break;
case 2: // sleepy: ears droop slowly
pose(60, 120, 1500); delay(2000); pose(80, 100, 1500); delay(2000); break;
}
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Press the button | Mood changes |
| Clap | Ears perk up for a moment |
| Sleepy mood | Slow droop and rise |
| Battery on | Works for an hour or more |
If it does not work
Ears jitter
Add a capacitor across the servo supply and check the ground.
Reset on movement
Use a better battery or slower moves.
Always startled
Turn the module's screw to lower sensitivity.
Servos too weak
Reduce the ear weight.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the moving cat ears headband?
Seeed XIAO RP2040, SG90 Micro Servo × 2, Sound sensor module (KY-038), Tactile push button 6 mm and Li-Po battery 3.7 V 1000 mAh.
How long does the moving cat ears headband take to build?
About 120 minutes for a beginner maker, in 7 steps.
How do I know the moving cat ears headband works?
Press the button: Mood changes. Clap: Ears perk up for a moment. Sleepy mood: Slow droop and rise.
Ears jitter: what should I check?
Add a capacitor across the servo supply and check the ground.
Reset on movement: what should I check?
Use a better battery or slower moves.
Always startled: what should I check?
Turn the module's screw to lower sensitivity.
Servos too weak: what should I check?
Reduce the ear weight.
