EV3 MicroPython comes with pre-recorded sound files. Here's how to program your robot to play them.

To access the full video please subscribe to FLLCasts.com
- #1627
- 04 Jun 2020
To play a sound file, you have to use the "ev3.speaker.play_file()" command and set the file you wish to play as an input parameter.
The sound file is called using the "SoundFile" class followed by the name of the sound file.
Example:
ev3.speaker.play_file(SoundFile.OKAY)
This command will play the "OKAY" sound file. If we wish to play the "BRAVO", we should change the code to the following:
ev3.speaker.play_file(SoundFile.BRAVO)
A full list of the sound files you can use with this class can be found in the "media" section of the PYBRICKS documentation.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Python with LEGO Mindstorms EV3 - Level 2
In the second level of Python for EV3 robots, students learn in-depth the touch sensor. The sensor is used as an input device for manual control of machines, as well as a sensor for autonomous robots. In a pair of lessons, students build a control panel for the grabber and the movement of a crane. Programming wise, students learn how to fork code with "if-else" constructions, how to create conditional and forever loops with "while" and how to negate conditions with "not" operator. In the end of the lesson, robots can detect obstacles and avoid them, so that they traverse a simple labyrinth.
- 39
- 19:58
- 93

Lesson 1 - Security system.
Introduction
In this lesson, we will create a system that checks if the exit of a supermarket is closed or if there are still more people in the building. In big supermarkets, security guards must reassure that all of the clients have left the premises before they've locked the door.
However, there is always the odd case of someone getting locked in by accident, which is why there are security systems that notify the security guards they have made a mistake.
- 5
- 5
- 10
- 3d_rotation 1