Playing Custom Imported Sounds in a VEXcode V5 Project

Playing custom imported sounds is a unique function in the VEXcode V5 software. This article will walk you through where and how to import sounds into VEXcode V5, the setup required to ensure the sounds play properly, and an explanation of how the play VEXcode sound command works.

VEXcode V5 Blocks

VEXcode V5 blocks project that reads When started, play VEXcode sound arrow, drive forward for 200 mm, and then play VEXcode sound game over.

VEXcode V5 Python

# Library imports
from vex import *

# Begin project code
play_vexcode_sound("arrow")
drivetrain.drive_for(FORWARD, 200, MM)
play_vexcode_sound("game over")

VEXcode V5 C++

// Include the V5 Library
#include "vex.h"

// Allows for easier use of the VEX Library
using namespace vex;

int main() {
  playVexcodeSound("arrow");
  Drivetrain.driveFor(forward, 200, mm);
  playVexcodeSound("game over");
}

Select the image above to enlarge.

Accessing the Play VEXcode Sound Command

By default, the play VEXcode sound command does not appear in the toolbox on the left side of the screen. The following steps explain how to enable the command.

VEXcode V5 Toolbar with the File menu open and the Tools submenu open. The Manage VEXcode Sounds option is inside the Tools submenu and it is highlighted.

Navigate to the File menu. Select ‘Tools’ and ‘Manage VEXcode Sounds.’

Note: this image shows blocks in the toolbox but the process is the same for C++ and Python projects.

VEXcode V5 Manage VEXcode Sounds menu that contains a list of imported sounds and their file locations. The menu also has a checkbox to Enable VEXcode Sounds, and two buttons below that read Cancel and Save Sounds.

The Manage VEXcode Sounds menu will then appear.

VEXcode V5 Manage VEXcode Sounds menu with the Enable VEXcode Sounds checkbox ticked and highlighted.

Select the check box to enable the play VEXcode sound command.

Functionality of the Manage VEXcode Sounds Menu

The Manage VEXcode Sounds menu is used to add sounds, edit sound names, and delete sounds.

Add a sound

VEXcode V5 Manage VEXcode Sounds menu with the next blank line in the sound list highlighted. The new line has a space for the sound's name and another space for its file URL.

Find an open row.

VEXcode V5 Manage VEXcode Sounds menu with the next blank line in the sound list highlighted and the name arrow entered.

Enter the sound name into the associated ‘Name’ box.

When you input a new name, a blank row appears below the current row.

VEXcode V5 Manage VEXcode Sounds menu with the next blank line in the sound list highlighted. The name has been set to arrow and the new sound file URL has been entered.

Paste the associated sound file URL into the same row as the new name.

VEXcode V5 Manage VEXcode Sounds menu with the Save Sounds button highlighted.

When finished, select ‘Save Sounds.’

VEXcode V5 Manage VEXcode Sounds menu with the Cancel button highlighted.

To edit the Manage VEXcode Sounds menu, select ‘Cancel.’

Save changes before hitting 'Cancel' to avoid losing any edits.

Delete a sound

VEXcode V5 Manage VEXcode Sounds menu with the trash can icon next to the new arrow sound highlighted. Each custom sound has a trash can icon next to it.

Click the trash can icon to delete the sound linked to that row.

VEXcode V5 Manage VEXcode Sounds menu with the Save Sounds and Cancel buttons highlighted.

Select ‘Save Sounds’ to save the changes or ‘Cancel’ to exit the menu.

Note: at least one sound must always be listed in the table. The trash can icon will be grayed out when only one sound is left, to ensure one sound remains.

Edit a sound

VEXcode V5 Manage VEXcode Sounds menu with the new arrow sound highlighted.

You can edit a sound’s name or file URL by selecting it.

VEXcode V5 Manage VEXcode Sounds menu with the Save Sounds and Cancel buttons highlighted.

Select ‘Save Sounds’ to save the changes or ‘Cancel’ to exit the menu.

Connecting to the User/Console Port

To play custom sounds in web-based VEXcode V5, a connection to the user/console web-serial port is needed. This second port is needed because the first serial port links the V5 Brain to the device for project downloads from a browser.

VEXcode V5 Toolbar with the green Brain icon selected in between the Controller and Download icons. The Brain dropdown menu has a highlighted button below that reads Connect User / Console Serial Port.

For steps on how to connect the V5 Brain to the user/console port, view this article.

V5 Brain is connected to a laptop using a USB cable.

To play custom sounds, the V5 Brain MUST stay connected to the device via a USB cable while using the user/console web-serial port.

Using the Play VEXcode Sound Command

Drag and attach or type the play VEXcode sound command to your project. For more information on how the block functions, view the Help.

VEXcode V5 Blocks

VEXcode V5 blocks project that reads When started, play VEXcode sound game over.

VEXcode V5 Python

# Library imports
from vex import *

# Begin project code
play_vexcode_sound("game over")

VEXcode V5 C++

// Include the V5 Library
#include "vex.h"

// Allows for easier use of the VEX Library
using namespace vex;

int main() {
  playVexcodeSound("game over");
}

Select the image above to enlarge.

Volume icon to indicate that the laptop's volume and speakers are used when playing sounds.

Since the sounds play through the connected device, ensure the volume is up when playing sounds.

V5 Brain is connected to a laptop using a USB cable.

Ensure the V5 Brain remains connected to the device via a USB cable while the project is downloaded and running.

Note: custom sounds are stored into the VEXcode V5 project and will function as long as the specific project is loaded. If VEXcode V5 is closed or a new project is loaded, the sounds will not operate. However, upon reloading the original project file, the custom sounds will resume playing as anticipated.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: