The noise sensor add-on measures the overall noise level. It can detect loud sounds, such as a clap, or show the envelope of a sound. It does not work like a microphone that records or distinguishes specific sounds.
Front of the noise sensor, showing the microphone, sensitivity adjustment and noise level LED.
Back of the noise sensor, showing the I²C connectors, microcontroller and other circuitry.
Set Up
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 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.
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.
Turn the sensitivity trimmer to change how much noise activates the sensor.
Using with Blocks
Open 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.
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.
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.
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:
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.
The Ball sprite reads the shared variable and draws each point using the Pen extension.
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.