Adding audio elements to components
In this course, you will learn how to add and control audio elements to components in Simumatik.
System overview
Start by loading the system called Introduction to Pneumatics.
The system contains two different pneumatic cylinders, one single-actuating cylinder controlled by a button and one double-actuating cylinder controlled by a joystick.

Running the system
Press ‘Play’ to start the emulation. By pressing the button on the valve_3_2_way_button the lower cylinder pushes forward. By releasing the button the cylinder retracts.
By controlling the joystick on valve_5_2_way_joystick the the other cylinder pushes forward or retracts.

Modify a component
Now it’s time to start modifying the component. In the Assemblies pane select the single_acting_cylinder and choose edit.


Next select the editor pane and add an audio element to the base_link.

Expand the tree and select file for the audio element.

Select behavior in the tree and add a new variable. Rename the variable to play_sound and modify it to be an output.
Drag-and-drop the play property for the audio element to the play_sound variable, as shown below.

Modify the script to set the variable play_sound when the cylinder retracts. See line 11 and 15 below. Save the script and save the component and leave the component editor.

Now the cylinder will play the sound when it retracts. Play around!