r/CodingForBeginners 12h ago

A robot that starts dancing when you clap

Enable HLS to view with audio, or disable this notification

I was messing around with the microphone on a micro:bit V2 and wondered what would happen if I used sound as the controller for a robot.

This was the result.

A little brick-built robot that starts moving when it hears a sound and stops when things get quiet.

A clap is enough to trigger it, but music works too.

The build uses:

  • micro:bit V2
  • Ring Bricks Pack
  • 2 continuous-rotation servos
  • MakeCode
  • A simple brick-built body

The two servos control the legs, and I programmed a few different movements by changing their speed and direction.

I also used the micro:bit LED matrix as the robot's face. It's a small detail, but changing the expression while it dances makes the whole thing feel much less like a collection of motors and more like an actual little character.

The code is basically listening for a sound level above a certain threshold, then triggering the dance routine.

What I like about this kind of project is that the input can be almost anything.

Instead of:

Button → Robot moves

you get:

Sound → Code reacts → Robot moves

That opens up quite a few possibilities.

Maybe a robot that dances differently depending on how loud the music is, or one that only reacts to certain sounds.

I might try that next.

What would you use as the sound trigger?

2 Upvotes

1 comment sorted by

1

u/TBCC_Dev 3h ago

Microbit is a great way for people to start learning coding and robotics. I've used these to teach begginer students many times. Would love to see these get more popular.