Main Content

Speaker

Play tone from EV3 speaker

Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.

Library

Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware

  • Speaker block

Description

Play tones from the speaker inside the EV3 brick.

To play a tone, set the speaker volume and frequency to values that are audible.

To stop playing a tone, send a 0 to either block input.

The speaker can produce audible sound from approximately 32 to 13000 Hz.

The speaker volume ranges from 0 to 100 (lowest to highest).

You can disable either one of the block inputs using the Input mode parameter. For example, to always play 440 Hz, you can set Input mode to Volume only, and then set Frequency (Hz) to 440.

This block converts the data type of the values it receives. You do not need to convert the data type of the input signal.

During simulations without hardware, this block does nothing. See Block Produces Zeros or Does Nothing in Simulation.

Parameters

Input mode

Enable or disable the block inputs:

  • Frequency and volume — Enables both Freq and Vol.

  • Volume only — Enables the Vol block input, disables the Freq block input, and enables the Frequency (Hz) parameter on the block mask.

  • Frequency only — Enables the Freq block input, disables the Vol block input, and enables the Volume (0 - 100) parameter on the block mask.

Frequency (Hz)

Enter the frequency of the tone the speaker emits. When the Input mode parameter is configured to enable a Freq input, this parameter is not available.

Volume (0 - 100)

Set the volume of the tone the speaker emits. When the Input mode parameter is configured to enable a Vol input, this parameter is not available.

Duration (ms)

Play a continuous tone or an intermittent tone (beeps). If this value is equal to or greater than the sample time of the source block, the speaker emits a continuous tone. If this value is shorter than the sample time of the source block, the speaker emits an intermittent tone at each sample period. For example, if the sample time of a source block is 0.1 seconds, and the speaker duration is 100 milliseconds (0.1 seconds), the speaker plays a continuous tone. If you change the speaker duration to 50 milliseconds, the speaker emits a beep every 0.1 seconds.