sonometre.ino

Arduino Esplora — Board Fiche · File : sonometre.ino · Language : Arduino · Use case : Mesurer le niveau sonore ambiant avec le microphone embarqué

The microphone returns ambient amplitude: clap and watch the LED pulse. This is the basis of air instruments and noise detectors, with no external part.

Hardware required

An Arduino Esplora (ATmega32U4, 5 V) with its onboard sensors: joystick, 4 buttons, slider, RGB LED, buzzer, light, temperature, sound and accelerometer. None.

Wiring

Nothing to wire; get close to test.

How it works

readMicrophone samples the mic; the raw value maps to RGB LED brightness. In the Arduino IDE, select « Arduino Esplora »; add the « Esplora » library from the Library Manager to reach the onboard sensors.

Going further

Trigger a melody on a clap (threshold + timeout), or log the sound envelope over serial.

sonometre.ino

// Microphone embarque -> niveau sonore en serie + pulsation lumineuse.
#include <Esplora.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  int v = Esplora.readMicrophone(); // 0..1023
  Serial.println(v);
  int lueur = map(v, 0, 1023, 0, 255);
  Esplora.writeRGB(lueur, lueur / 2, 0); // pulsation chaude sur le bruit
  delay(20);
}

← Back to the board