Build it step by step
0 of 7 doneWire the sound module
AO to A0, VCC to 5V, GND to GND.
Wire the eight lights
D2 to D9 through 330 ohm resistors, short legs to GND.
Wire the button
One leg to D10, the other to GND.
Upload the sketch
The bar sits at zero in a quiet room.
Clap once
The bar jumps and the peak light holds.
Turn the module's knob
A clap now lights about half the bar.
Press the button and make noise
After five seconds the best level stays lit.
How do you build an applause meter?
A row of eight lights rises with the loudness of clapping, a single light holds the peak for a moment, and the loudest of the round is shown at the end. A fun party game for a class, and a gentle way to learn about peak hold and loudness. Keep claps and cheers at a sensible level. You need Arduino Nano, Sound sensor module (KY-038), LED 5 mm red × 5, LED 5 mm green × 3, Resistor 330 Ω × 8, Tactile push button 6 mm, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 80 minutes.
- Level
- Beginner
- Time
- About 80 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SemiconductorsBuyLED 5 mm red × 5
- SemiconductorsBuyLED 5 mm green × 3
- PassivesBuyResistor 330 Ω × 8
- SwitchesBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Sound module AO | Nano A0 | The analog loudness signal |
| Sound module VCC and GND | Nano 5V and GND | Power |
| Green LEDs 1 to 3 | Nano D2, D3 and D4 through 330 ohm resistors | Long legs to the resistors, short legs to GND |
| Red LEDs 4 to 8 | Nano D5, D6, D7, D8 and D9 through 330 ohm resistors | Same way round |
| Round button | Nano D10 and GND | Starts a five second round |
Code
The sound module's analog pin gives a signal that wobbles up and down around the middle as sound reaches it. To measure loudness the sketch reads the pin as fast as it can for 20 milliseconds and keeps the lowest and highest readings, and the gap between them is the loudness. That number is turned into a level from 0 to 8 with a table of thresholds that roughly double each step, which matches how we hear loudness. The eight lights show the level as a bar, with the first three green and the last five red. A single peak light stays at the highest level for 700 milliseconds and then falls back one light at a time, like the meters on a mixing desk. Press the button and a five second round begins, and at the end the loudest level of the round stays lit for three seconds and is printed on the Serial Monitor. Turn the small knob on the sound module to set how sensitive it is, so that a clap lights about half the bar. Use a 330 ohm resistor with every light. Keep claps and cheers at a sensible volume, and do not put your ear next to a speaker or a shout just to light the top light. Each class can take turns for a round and compare their best levels.
Runs on a virtual Arduino Nano 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).
// No extra libraries.
const uint8_t LEDS = 8;
const uint8_t LED_PIN[LEDS] = {2, 3, 4, 5, 6, 7, 8, 9};
const uint8_t BTN_PIN = 10;
const uint8_t MIC_PIN = A0;
// Loudness (peak to peak, 0..1023) needed to light each LED. Roughly doubling steps.
const int THRESH[LEDS] = {15, 30, 50, 80, 120, 180, 270, 400};
const unsigned long PEAK_HOLD_MS = 700;
const unsigned long ROUND_MS = 5000;
int peakLevel = 0; // 0..8, the held peak light
unsigned long peakTime = 0;
bool inRound = false;
unsigned long roundStart = 0;
int roundBest = 0; // loudest level this round
int roundBestAmp = 0;
bool prevBtn = false;
int ampOver20ms() { // peak to peak over a short window
int lo = 1023, hi = 0;
unsigned long start = millis();
while (millis() - start < 20) {
int v = analogRead(MIC_PIN);
if (v < lo) lo = v;
if (v > hi) hi = v;
}
return hi - lo;
}
int levelFor(int amp) {
int lvl = 0;
for (uint8_t i = 0; i < LEDS; i++) if (amp >= THRESH[i]) lvl = i + 1;
return lvl;
}
void showBar(int level, int peak) {
for (uint8_t i = 0; i < LEDS; i++) {
bool on = (i < level) || (peak > 0 && i == peak - 1);
digitalWrite(LED_PIN[i], on ? HIGH : LOW);
}
}
void setup() {
for (uint8_t i = 0; i < LEDS; i++) pinMode(LED_PIN[i], OUTPUT);
pinMode(BTN_PIN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
bool b = (digitalRead(BTN_PIN) == LOW);
if (b && !prevBtn && !inRound) { // start a round
inRound = true;
roundStart = millis();
roundBest = 0;
roundBestAmp = 0;
Serial.println(F("Round started: make some noise!"));
}
prevBtn = b;
int amp = ampOver20ms();
int lvl = levelFor(amp);
if (lvl >= peakLevel) { peakLevel = lvl; peakTime = millis(); }
else if (millis() - peakTime > PEAK_HOLD_MS) { if (peakLevel > 0) peakLevel--; peakTime = millis() - PEAK_HOLD_MS + 80; }
if (inRound) {
if (amp > roundBestAmp) { roundBestAmp = amp; roundBest = lvl; }
if (millis() - roundStart > ROUND_MS) { // round over: show the best for three seconds
inRound = false;
Serial.print(F("Loudest level: "));
Serial.print(roundBest);
Serial.print(F(" of 8, amplitude "));
Serial.println(roundBestAmp);
showBar(roundBest, 0);
delay(3000);
peakLevel = 0;
}
}
showBar(lvl, peakLevel);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Quiet room | One light or none |
| Normal talking | Two to four lights |
| One clap | A tall bar and a held peak light |
| Press the button | Five second round starts |
| End of round | Loudest level held for three seconds |
| Serial monitor | Prints the best level |
If it does not work
Top lights always on
Turn the module's knob to lower the sensitivity.
Nothing lights
Turn the knob up and check AO goes to A0.
A light never lights
Check its resistor and the direction of the LED.
Round never starts
Check the button goes to D10 and GND.
Bar flickers
Normal for speech, the peak light shows the top.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the applause meter?
Arduino Nano, Sound sensor module (KY-038), LED 5 mm red × 5, LED 5 mm green × 3, Resistor 330 Ω × 8, Tactile push button 6 mm, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the applause meter take to build?
About 80 minutes for a beginner maker, in 7 steps.
How do I know the applause meter works?
Quiet room: One light or none. Normal talking: Two to four lights. One clap: A tall bar and a held peak light.
Top lights always on: what should I check?
Turn the module's knob to lower the sensitivity.
Nothing lights: what should I check?
Turn the knob up and check AO goes to A0.
A light never lights: what should I check?
Check its resistor and the direction of the LED.
Round never starts: what should I check?
Check the button goes to D10 and GND.
