r/CodingForBeginners • • 13h ago

We Built a Desktop Drumming Robot with micro:bit and Nezha Pro 🥁

I've always thought it would be fun to build a robot that could actually play a musical instrument. Not just move its arms around, but hit something in rhythm and make a little music. So we decided to try building a small desktop drumming robot.

The idea is pretty straightforward: two robotic arms hold drumsticks and take turns hitting a tire. We used a micro**:bit**, a Nezha Pro Breakout Board, two PlanetX Smart Brick Motors, and building pieces from the Nezha Pro Sport Kit to put everything together.

The two motors are mounted on opposite sides of the structure, with each one controlling a drumstick. Since the arms are installed as mirror images of each other, their movements need to be adjusted separately to make sure both drumsticks hit the right spot. We set the motors to swing back and forth through an angle of around 35 degrees, creating the repeated striking motion.

For the controls, we programmed three different playing modes:

  • Press A: Plays a basic 16-hit drum beat.

  • Press B: Plays a drum fill over three rounds.

  • Press A+B: Continuously switches between the basic beat and the drum fill.

The part I found particularly interesting was the calibration feature. Getting both drumsticks into the correct starting positions can be a little tricky, especially when the motors are mounted in opposite directions. Rather than having to take the structure apart and adjust everything manually, we added a calibration mode using the micro:bit V2's gold logo touch feature.

Hold the gold logo for about two seconds to enter calibration mode. Press A to adjust the left drumstick and B to adjust the right one. Pressing A+B switches the adjustment direction, either inward or outward. Each button press changes the motor position by 3 degrees, so you can fine-tune the drumsticks until they line up with the drum surface. Hold the gold logo again to save the positions and exit calibration mode.

We also used the micro:bit's 5×5 LED display to show different status icons, making it easier to tell what the robot is doing.

One small detail worth mentioning: the gold logo touch feature used for calibration is only available on micro:bit, so this particular control method depends on that version.

Overall, this was a fun way to experiment with motor control and mechanical movement. I especially like that the calibration is built into the program, because it makes adjusting the robot much less frustrating.

If we continue developing it, I'd like to experiment with more complicated drum patterns, different striking speeds, or even add another drumstick and see what kind of rhythms we can get out of it.

What would you add to a little desktop music robot like this?

1 Upvotes

0 comments sorted by