Source: https://mokxi.com/teachers/plans/sound-and-audio
Updated: 2026-11-19

Lesson plan

# Sound and audio on microcontrollers lesson plan

Make sound and hear it, on the Uno and the ESP32: square waves with tone(), a sine from PWM, an MCP4725 DAC and its speed limit, I2S to a MAX98357A, recorded clips on a DFPlayer, an INMP441 microphone, and a spaceship voice clock.

4 chapters, 7 lessons, about 6 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Square waves, PWM samples and a real voltage from a DAC.
- I2S out to a speaker, and recorded clips from a card.
- An I2S microphone: level, decibels and pitch.
- A talking clock built from recorded words.

### Materials for the whole unit

- Arduino Uno R3
- Capacitor x 2
- DAC, MCP4725
- DFPlayer Mini MP3 module
- ESP32 DevKit V1
- Frequency counter x 2
- Half breadboard
- I2S amplifier, MAX98357A
- I2S microphone, INMP441
- Oscilloscope
- Piezo speaker
- Pushbutton x 2
- Resistor x 2
- Speaker, 8 ohm

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h 25 min

## Making a waveform

Square waves, PWM samples and a real voltage from a DAC.

Lesson | Time | What students do

Tone and square waves A piezo on pin 8 plays a coin pickup, a power-up and a laser sweep: tone() makes a square wave, and the piezo and a frequency counter read the pitch back, to the hundredth of a hertz. | 50 min

- Play the coin sound
- The pitch you really get
- The counter agrees
- A power-up chord
- A laser sweep
- What a square wave is
- A brighter coin

PWM audio A real sine from a pin that can only be HIGH or LOW: 62.5 kHz PWM, a sample table played 8000 times a second by a timer interrupt, and two RC stages that smooth it into 440 Hz. | 50 min

- Run it
- The carrier
- The filter keeps the tone
- Samples and a phase accumulator
- The rules of sampling
- An octave up
- Where PWM audio is used

The MCP4725 DAC A 12-bit DAC on I2C puts out a real voltage, no PWM and no filter. Then its speed limit: the sketch measures its own sample rate, and the pitch it can reach. | 45 min

- A real voltage
- Count the samples
- The counter agrees
- The full swing
- Why the bus is the limit
- Fewer points, higher pitch

### Materials

- Arduino Uno R3
- Capacitor x 2
- DAC, MCP4725
- Frequency counter x 2
- Oscilloscope
- Piezo speaker
- Resistor x 2

### Check for understanding

Each student finishes "The MCP4725 DAC" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Fewer points, higher pitch".

Chapter 2. About 1 h 40 min

## Digital audio

I2S out to a speaker, and recorded clips from a card.

Lesson | Time | What students do

I2S with the MAX98357A An ESP32 sends a sine as 16-bit samples over I2S to a MAX98357A, which drives an 8 ohm speaker by itself. Then the amplifier’s gain and shutdown pins, wired on the canvas. | 50 min

- Samples over a bus made for audio
- The speaker plays A4
- Read the amplifier
- Wire the gain
- Shut it down
- An octave up
- Why I2S

DFPlayer clips A DFPlayer Mini decodes recorded clips from a microSD card and drives the speaker itself; the Uno sends it commands over serial. Two buttons, a BUSY pin and a spaceship sound board. | 50 min

- A sound board
- Play a clip
- The BUSY pin
- Next clip
- When a clip ends
- Start somewhere else
- Clips or synthesis

### Materials

- Arduino Uno R3
- DFPlayer Mini MP3 module
- ESP32 DevKit V1
- Half breadboard
- I2S amplifier, MAX98357A
- Pushbutton x 2
- Resistor
- Speaker, 8 ohm

### Check for understanding

Each student finishes "DFPlayer clips" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Clips or synthesis".

Chapter 3. About 50 min

## Listening

An I2S microphone: level, decibels and pitch.

Lesson | Time | What students do

The INMP441 microphone Sound in: an INMP441 sends 24-bit samples over I2S to an ESP32, which works out the level in dBFS from their RMS and the pitch from counting zero crossings, and flags when it gets loud. | 50 min

- A microphone with its own ADC
- How loud
- A pure tone
- dB SPL and dBFS
- Is it listening?
- A clap detector
- What the microphone hears here

### Materials

- ESP32 DevKit V1
- I2S microphone, INMP441

### Check for understanding

Each student finishes "The INMP441 microphone" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "What the microphone hears here".

Chapter 4. About 1 h

## Boss project

A talking clock built from recorded words.

Lesson | Time | What students do

Boss: a talking clock A spaceship voice clock: a DFPlayer strings number clips into "ship time is eight o’clock", a button asks for the time, and a piezo chimes ding-dong on the hour. | 60 min

- Mission clock online
- Ship time
- Ask the time
- Hear it start
- The hour chime
- On the hour
- Announce the hour
- Make it yours

### Materials

- Arduino Uno R3
- DFPlayer Mini MP3 module
- Half breadboard
- Piezo speaker
- Pushbutton
- Resistor
- Speaker, 8 ohm

### Check for understanding

Each student finishes "Boss: a talking clock" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
