Main Content

Speaker

Play tune from EV3 speaker

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

  • Lego Speaker block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware

Description

Use the Speaker block to play tones from the speaker in the EV3 brick. To play a tone, set the speaker volume and frequency to values that are audible.

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 emits zeros. See Block Produces Zeros or Does Nothing in Simulation.

Ports

Input

expand all

The block inputs the frequency of the tone the EV3 speaker emits. The speaker can produce audible sound from approximately 32 to 13000 Hz. To stop playing a tone, input 0 to this block input.

Dependencies

  • To enable this port, set Input mode to Frequency and volume or Frequency only.

Data Types: uint32

The block inputs the volume of the tone the EV3 speaker emits. The speaker volume ranges from 0 to 100 (lowest to highest). To stop playing a tone, input 0 to this block input.

Dependencies

  • To enable this port, set Input mode to Frequency and volume or Volume only.

Data Types: uint32

Parameters

expand all

Select from these parameters to accept either frequency, volume, or both of the tone.

  • Frequency and volume — Accept both frequency and volume of the tone as inputs to the block.

  • Frequency only — Accepts only volume of the tone as input to the block.

  • Volume only — Accepts only frequency of the tone as input to the block.

Set volume of the tone the EV3 speaker emits.

Dependencies

  • To enable this parameter, set Input mode to Frequency only.

Enter frequency of the tone the EV3 speaker emits.

Dependencies

  • To enable this parameter, set Input mode to Volume only.

Set the duration to play a continuous tone or an intermittent tone (beeps) from the EV3 speaker. 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.

Version History

Introduced in R2012a