All builds →
Build 02

Making it giggle on command

Post 01 gave us giggles. Now the classic first win of coding — making one play on command: press a key on your laptop, or boop the robot itself if you've got one. Hello, world.

🕓 ~15 min 🤖 any AI app 🧒 kids 7+ 💻 a little Python (we'll help)
Same three parts as always — the Goal, the Explore (prompts you paste into your AI), and the Output (the code + the sound; press play) — plus an optional bonus to think about at the end. No robot yet? Your laptop is the robot for today.
Just want to see it work? Install the ready-made app on your Reachy Mini — no code needed — then boop it. Or read on and build it yourself.
Get the app →
1

The goal

Make your code do a thing

In Post 01 we made a folder of giggles. Fun — but the real magic is when your own code makes one play on command. That's “hello world”: the tiny first program that proves you can make a computer do something. We'll make a giggle play every time you press Enter.

Don't have the robot yet? Your laptop is the robot today — same code, same lesson. Have a Reachy Mini Wireless? The last prompt swaps the keyboard for the robot's own motion sensor, so you set off the giggle by booping it.

2

The explore

Four prompts to a talking robot

Open your AI app and paste these one at a time. Prompt 4 is only if you have the robot — skip it happily if you don't.

① · Paste to your AI
Get Python ready

I'm on a Mac (or Windows). Walk me through installing Python and running a .py file, explained for a total beginner. Keep it short.

What to expect A quick one-time setup. (On a Mac, Python is often already there.) This is the only "install" step in the whole post.

② · Paste to your AI
The hello-world

Write the simplest possible Python program that plays a sound file called giggle.wav every time I press Enter, and keeps going until I stop it. Explain the two key lines.

What to expect A tiny loop: wait for Enter, then play the sound. That "wait, then act" shape is the seed of every app, game, and robot behaviour you'll ever build.

③ · Paste to your AI
Make it playful

Now pick a random giggle from a folder of .wav files each time, so it's a surprise, and print a fun message each time.

What to expect Randomness = replay value. Your kid will press Enter fifty times to hear which one comes next. Let them.

④ · Paste to your AI
Boop the robot instead of the keyboard

I have a Reachy Mini Wireless. It has a built-in IMU motion sensor (reachy_mini exposes it as robot.imu, a dict with 'accelerometer' and 'gyroscope'). Write a program that plays giggle.wav through the robot's speaker whenever I nudge, wiggle, or pick up the robot, and makes it nod its head and wiggle its antennas while it giggles.

What to expect Now the trigger lives on the robot, not the laptop: touch it and it giggles. That IMU is the same kind of chip that knows which way up your phone is (it's on the Wireless, not the Lite).

🧒 Kid's corner — Let them be the trigger designer. Should it giggle when you press Enter? When you type the letter g? Every ten seconds? Deciding when it reacts is real design thinking — and it's the whole job of Post 03.
3

The output

The code (and the giggle)

Here's the giggle our program plays — press play. Save your giggle.wav from Post 01 next to the script, run it, and press Enter.

On any computer. Two lines do the work: input() waits for you, playsound(...) reacts. Wait, then act — that's every program you'll ever write.

# one-time: pip install playsound==1.2.2
from playsound import playsound

print("Press Enter to giggle. Ctrl-C to stop.")
while True:
    input()                   # 1) wait for you to press Enter
    playsound("giggle.wav")   # 2) then play the giggle

On the robot — boop it. The Wireless has a built-in motion sensor, so the trigger becomes touching the robot: nudge, wiggle, or pick it up, and it nods and wiggles its antennas as it laughs. The 1.5 is the ticklishness dial — lower it for a hair-trigger, raise it for a real shake.

import time, numpy as np
from reachy_mini import ReachyMini
from reachy_mini.utils import create_head_pose

with ReachyMini() as robot:                          # connect to the robot
    print("Boop or wiggle the robot to make it giggle! (Ctrl-C to stop)")
    while True:
        imu = robot.imu                              # the built-in motion sensor
        if imu:
            spin = np.linalg.norm(imu["gyroscope"])  # how much it's being moved
            if spin > 1.5:                           # someone booped it!
                robot.media.play_sound("giggle.wav") # giggle out of its speaker
                for k in range(30):                  # laugh: nod the head + wiggle antennas
                    nod = 12 * np.sin(k / 2.5)       # head bobs up and down (degrees)
                    a = 0.4 * np.sin(k / 1.5)        # antennas swing
                    robot.set_target(head=create_head_pose(pitch=nod), antennas=[a, -a])
                    time.sleep(0.03)                 # ~0.9s of happy laughing
        time.sleep(0.02)

Where next? You've got a robot that reacts to you. In Post 03 we let it react to what it sees — wave hello, and get a giggle back.

★

The bonus

Something to think about

Skip this if you like — the robot giggles either way. But something happens the first time it laughs when you nudge it: you apologise to it, or you nudge it again just to hear it. Everyone does. It's worth asking why, especially with an older kid.

★ · Paste to your AI
Why does it feel alive?

Explain to a 9-year-old why people feel like something is alive when it reacts to them — even when they know it's a machine following one simple rule. Then explain how the robot's accelerometer senses movement, and which part of the human body does the same job.

What to expect Two good halves. One about us: we're wired to read a reaction as a feeling. One about the sensor — an accelerometer senses movement much like the vestibular system in your inner ear, which is how you know you're being tipped over with your eyes shut.

Then talk about it:

💡 Today we learned — feeling something for a machine isn't a mistake, and it isn't proof the machine feels anything back — both are true at once. Knowing exactly which line makes it laugh is the best protection against being fooled by it. It's still funny anyway.