The noise sensor add-on measures the overall noise level. It can detect loud sounds, such as a clap, or show the [[https://en.wikipedia.org/wiki/Envelope_(waves)|envelope]] of a sound. It does not work like a microphone that records or distinguishes specific sounds. {{ :martyv2:userguides:sensorsandaddons:20210907_152018.jpg?400 |Front of the noise sensor}} //Front of the noise sensor, showing the microphone, sensitivity adjustment and noise level LED.// {{ :martyv2:userguides:sensorsandaddons:noise-sensor-back.jpg?400&nolink |Back of the noise sensor}} //Back of the noise sensor, showing the I²C connectors, microcontroller and other circuitry.// ===== Set Up ===== {{ youtube>ldpIoseIfVI?medium }} The noise sensor fits either attachment point on Marty's feet: at the front or the back. ==== Step 1: Decide where to mount the sensor, and ensure you have a free cable ==== You may need to unscrew and disconnect an existing sensor to make space. Alternatively, mount the noise sensor at the back of the foot. ==== Step 2: Connect the cable to the noise sensor ==== Connect the black I²C cable to either socket on the noise sensor. Either socket can be used. ==== Step 3: Fix the noise sensor board to Marty ==== Use two M3 nuts and bolts to secure the noise sensor to the foot. ===== Checking and Configuring the Sensor ===== - Open [[https://robotical.app/|the Robotical app]] and connect to Marty. - Open **Robot settings** using the robot-and-cog button at the bottom left, then select **Add-ons** to open **Manage Add-ons**. - Find the entry with the type **noisesensor** and expand it using its cog button. {{ :martyv2:userguides:sensorsandaddons:noise-addon-current-2026.jpg?780&direct |Noise sensor configuration in Manage Add-ons}} //Illustrative noise sensor entry in the current Manage Add-ons screen. Use the name and details shown for your own attached sensor.// The sensor may initially have a default name, such as ''AddOn_I2CB_27''. You can leave that name as it is. To rename it, enter a name under **Name this add-on** and select **Update Name**. The examples below use ''NoiseSensor''. If you have more than one noise sensor, give each one a different name so you can select the right sensor in Blocks. ===== Using the Noise Sensor ===== Marty must run on battery power for the noise sensor to work correctly. Readings may be less reliable when Marty is powered by USB. ==== Noise Level LED ==== The white LED on the board lights up when the sensor detects noise. Try whistling or clapping near the sensor to see it react. ==== Tuning the sensitivity ==== Use a small screwdriver to turn the sensitivity trimmer on top of the board. {{ :martyv2:userguides:sensorsandaddons:20210907_1520158.jpg?400 |Adjusting the noise sensor's sensitivity}} //Turn the sensitivity trimmer to change how much noise activates the sensor.// ===== Using with Blocks ===== Open [[https://robotical.app/blocks|Blocks]] and select your connected Marty in the device list. Under **Sensing**, find the **Noise sensor** reporter and select your sensor's name from its dropdown. The examples use ''NoiseSensor''; select the name shown for your own sensor in **Manage Add-ons**. A higher reading means more noise. These are relative sensor readings, not calibrated decibels. {{ :martyv2:userguides:sensorsandaddons:noise-block-current-2026.jpg?nolink&430 |The current Noise sensor reporter in Blocks}} //The current Noise sensor reporter, with NoiseSensor as an example name.// Tick the checkbox beside the reporter in the **Sensing** palette to show a live reading on the stage when your sensor is connected. ==== Example: Clap activated Marty ==== This example uses two quick claps to make Marty dance. Create a variable called ''Clap counter'' and build the program below on your Marty device. {{ :martyv2:userguides:sensorsandaddons:noise-clap-current-2026.jpg?nolink&598 |Blocks program for double-clap activated dancing}} //Double-clap example using a sensor named NoiseSensor.// The program counts readings above ''50''. After each detection, it resets the timer and waits ''0.25'' seconds before checking again. If more than one second passes without another detection, it clears ''Clap counter''. When the counter reaches ''2'', Marty dances, then waits one second before starting again. Treat ''50'' as a starting threshold: adjust it to suit the sensor's sensitivity and the background noise. The sensor detects loudness rather than recognising claps, so other loud or sustained sounds can also trigger the program. {{ youtube>AJpdtCT1UF8?medium }} //The original demonstration of double-clap activated dancing.// ==== Example: Graphing the sensor output ==== Use a sprite and the **Pen** extension to draw a graph of the sensor readings. Create a variable called ''noise reading'' **for all sprites** so Marty and the sprite can share it. First, select your Marty device and build a script that repeatedly sets ''noise reading'' to the **Noise sensor** reporter: {{ :martyv2:userguides:sensorsandaddons:noise-graph-reader-current-2026.jpg?nolink&702 |Marty script that shares the noise sensor reading}} //Read the sensor on the Marty device and store its value in a shared variable.// Next, add a Ball sprite and the **Pen** extension. On the Ball sprite, build the drawing script below. It moves across the stage, using ''noise reading'' for the height of each point. The subtraction places the baseline near the bottom of the stage. {{ :martyv2:userguides:sensorsandaddons:noise-graph-current-2026.jpg?nolink&343 |Ball sprite program that graphs the shared noise reading}} //The Ball sprite reads the shared variable and draws each point using the Pen extension.// {{ :martyv2:userguides:sensorsandaddons:noise-graph-output-current-2026.jpg?nolink&780 |Illustrative sample noise graph with smaller bumps and two sharp spikes}} //This graph uses illustrative sample data to show smaller bumps and two sharp spikes. It is not a recording from a connected noise sensor.// With your sensor connected, click the green flag to run both scripts. The drawing script plots ''100'' readings at roughly ''0.1''-second intervals, giving about ten seconds of sound levels. Try whistling and clapping near the sensor and compare the shapes in your own graph.