Double-clap light switch
Clap twice and the lights come on. Clap twice again to switch them off.
Shop by category
Shop all componentsElectret microphones give a tiny signal that must be amplified before an Arduino can read it. The MAX4466 module has fixed gain set by a small trimmer. The MAX9814 has automatic gain control (AGC): it turns itself down for loud sounds and up for quiet ones. The Nano measures the peak-to-peak swing of each over 50 ms and draws two bars, so you can clap, talk and whisper and see the difference.
Protect your hearing: do not test with very loud sounds close to your ears.
Tick anything you already have and the total updates.
MAX4466 microphone amplifier, adjustable gain
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB.
two_mics.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
int p2p(int pin) {
int lo = 1023, hi = 0;
unsigned long t0 = millis();
while (millis() - t0 < 50) { int v = analogRead(pin); lo = min(lo, v); hi = max(hi, v); }
return hi - lo;
}
void bar(int y, const char* name, int v) {
oled.setCursor(0, y); oled.print(name);
oled.drawRect(50, y, 76, 10, WHITE);
oled.fillRect(50, y, map(constrain(v, 0, 600), 0, 600, 0, 76), 10, WHITE);
}
void setup() { oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE); }
void loop() {
int a = p2p(A0), b = p2p(A1);
oled.clearDisplay(); oled.setTextSize(1);
bar(10, "MAX4466", a); bar(35, "MAX9814", b);
oled.setCursor(0, 54); oled.print(a); oled.print(" / "); oled.print(b);
oled.display();
}
Gain too high or noisy USB power; turn the MAX4466 trimmer down or use a power bank.
That is the AGC working; it keeps the output level steady.
Check the outputs go to A0 and A1 and the mics have 3.3 V.
No, it shows relative loudness; a real meter needs calibration against a reference.
The Nano is too slow for good audio; an ESP32 or Pi with an I2S mic is better.
They set the maximum gain and how fast the AGC reacts.
6 parts: MAX4466 Electret Microphone Amplifier, Adjustable Gain, MAX9814 Microphone Amplifier Module with AGC, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 1 hour. The build on this page has 5 steps.
No. This page has the complete, tested code (two_mics.ino).
About ₹706 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Microphone pre-amplifiers; Peak-to-peak sound measurement; What automatic gain control does.
Protect your hearing: do not test with very loud sounds close to your ears.
Clap twice and the lights come on. Clap twice again to switch them off.
Plays a friendly ding-dong whenever someone walks into the shop or room.
Beeps and flashes any message in Morse, or key your own by hand.
Turn a membrane keypad into a two-octave piano.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.