Using the EV3 Speaker (2024)

  1. Documentation
  2. Tutorials
  3. Using the EV3 Speaker
  • Introduction
  • Tone Mode
    • beep command
    • tone sysfs Attribute
  • PCM Playback Mode
  • Volume control
    • amixer Command
    • alsamixer Command
  • More Fun!
    • Text-To-Speech
    • MP3 player

Introduction

The EV3 uses pulse-width modulation (PWM) to drive an amplifier that produces thesounds that you hear through the speaker. It has two modes of operation. The first,we call Tone mode (aka Beep mode). In Tone mode, the PWM is set to afrequency in the audible range. The sound you hear is a square wave.The second mode is called PCM Playback mode. In this mode, the PWM is operatedat a higher frequency. The high frequencies are (mostly) filtered out and we areable to reproduce a recorded sound.

Tone Mode

There are a couple of ways to control the speaker in Tone mode. Also worth anhonorable mention: if you plug a USB keyboard into the EV3 and pressCTRL+G, it will beep!

beep command

The beep man page has all you need to know.

Examples:

$ beep # 440 Hz for 200 ms$ beep -f 200 -l 500 # 220 Hz for 500 ms$ beep -f 262 -l 180 -d 20 -r 2 \-n -f 392 -l 180 -d 20 -r 2 \-n -f 440 -l 180 -d 20 -r 2 \-n -f 392 -l 380 -d 20 \-n -f 349 -l 180 -d 20 -r 2 \-n -f 330 -l 180 -d 20 -r 2 \-n -f 294 -l 180 -d 20 -r 2 \-n -f 262 -l 400 # twinkle twinkle little star

tone sysfs Attribute

TODO: using the tone attribute is not really recommended. This needs to beupdated with an example on how to use the Linux input subsystem instead.

We have also provided a way to play tones directly using the sysfs attribute/sys/devices/platform/snd-legoev3/tone.

Example:

$ cd /sys/devices/platform/snd-legoev3$ echo 1000 10000 > tone # play a 1 KHz tone for 10 seconds$ echo 440 > tone # play a 440 Hz tone (endless mode)$ echo 0 > tone # stop the tone 

PCM Playback Mode

PCM playback is implemented as an ALSA driver. This means that you can use justabout any Linux program out there that can play sound. We have found the bestcompromise between sound quality and CPU usage is to use a sample rate 22050 Hz.16000 Hz sounds pretty good too. Of course the speaker is so small, the soundquality is just not going to be “high quality” no matter what.

Example: Playing back a .wav file using aplay.

$ aplay my-file.wavPlaying WAVE 'my-file.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono

You must be a member of the audio group in order to use the sound driver.

Volume control

Again, there are a number of ways to do this. Currently, there is only a mastervolume control that controls both Tone mode and PCM Playback mode.

amixer Command

Documentation:

Example:

$ amixer get Playback,0 # get current volumeSimple mixer control 'Playback',0 Capabilities: volume volume-joined penum Playback channels: Mono Capture channels: Mono Limits: 0 - 256 Mono: 255 [100%]$ amixer set Playback,0 50% # set volume to 50%Simple mixer control 'Playback',0 Capabilities: volume volume-joined penum Playback channels: Mono Capture channels: Mono Limits: 0 - 256 Mono: 128 [50%]

alsamixer Command

Graphical volume controls.

┌───────────────────────────── AlsaMixer v1.0.25 ──────────────────────────────┐│ Card: LEGO Mindstorms EV3 speaker F1: Help ││ Chip: F2: System information ││ View: F3:[Playback] F4: Capture F5: All F6: Select sound card ││ Item: Playback Esc: Exit ││ ││ ┌──┐ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │ │ ││ │▒▒│ ││ │▒▒│ ││ │▒▒│ ││ │▒▒│ ││ │▒▒│ ││ └──┘ ││ 40 ││ <Playback> ││ │└──────────────────────────────────────────────────────────────────────────────┘

More Fun!

Text-To-Speech

$ espeak "hello, I am an EV3.> I like to talk because I am a robot.> Did you know that robots like to make sounds?> Beep. Boop. Dit. Dit. Meep.> I am just such a chatterbox." --stdout | aplayPlaying WAVE 'stdin' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono

Tip

Add a function like this to your ~/.bashrc file.

speak(){ espeak -a 200 -s 130 -v la --stdout "$@" | aplay --quiet}

Then you can simply use:

$ speak "Thanks to GeekDude for this idea!" # @G33kDude

MP3 player

$ sudo apt-get update$ sudo apt-get install mpg123 # or mpg321...$ mpg123 /home/ev3dev/Music/01-The\ Jumpin\'\ Jive.mp3 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3version 1.14.4; written and copyright by Michael Hipp and othersfree software (LGPL/GPL) without any warranty but with best wishesDirectory: /home/ev3dev/Music/Playing MPEG stream 1 of 1: 01-The Jumpin' Jive.mp3 ...MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereoTitle: The Jumpin' Jive Artist: Cab CallowayComment: Album: Minnie the Moocher [Universal]Year: 1989 Genre: Swing
Using the EV3 Speaker (2024)

FAQs

What are the voice commands for EV3? ›

The user can pick one of several commands: forward, backward (reverse), stop, forward slow, forward fast, disconnect, circles, right turn (turn right), left turn (turn left). The robot will follow the user's voice commands and perform the action for half a second before prompting the user for another command.

How do you record sound on Lego Mindstorms EV3? ›

You can use a microphone built in or connected to your computer. You can record up to 10 seconds of your own sound by clicking the record button. The recording will automatically stop after 10 seconds. Clicking the record button will overwrite any sound already recorded.

What are the advantages of EV3? ›

What are the advantages of EV3? The EV3 is a fantastic resource for teaching beginners basic robotics skills. It provides creative, hands-on practice. For those who already have robotics experience, the kit is a fun tool for expressing creativity and fine-tuning programming skills.

Why is my EV3 not working? ›

Make sure that one end of your USB cable is firmly inserted into a USB port on the computer and the other end is connected to the EV3 Brick. If you still can't see the EV3 drive, try a different port on the computer. If that doesn't work then maybe your cable is faulty or you need to reset the EV3 Brick.

How do you record loud noises? ›

Regardless of what route you take DO NOT handhold the recorder/phone. Place it on some solid surface, or tripod. Turn off any other sound sources in your room (TV, loud appliances)...and don't stomp around the house. Hit record, sit down quietly and get enough of the audio to prove your point.

What does EV3 stand for? ›

The "EV" designation refers to the "evolution" of the Mindstorms product line. "3" refers to the fact that it is the third generation of computer modules - first was the RCX and the second is the NXT. It was officially announced on January 4, 2013, and was released in stores on September 1, 2013.

Is EV3 better than robot inventor? ›

Robot Inventor motors. Compared to EV3, the new motors are much smaller, lighter, and more comfortable for building. I guess they will have less torque, but this won't be a problem since your robots will be much lighter.

What did Lego replace the EV3 with? ›

SPIKE Prime replaced MINDSTORMS EV3 and builds on the skills developed with MINDSTORMS EV3 and offers a more complex coding system using Icon Blocks, Word Blocks and Python coding. The SPIKE Prime hub comes with an improved 6x6 display matrix and 6 ports to connect sensors and motors.

Is EV3 being discontinued? ›

FLL has allowed for older versions to be used, and most likely won't stop that any time soon. They still allow NXT and RCX. LEGO discontinued EV3 in June 2021, so the only Mindstorms branded LEGO product at the moment is Robot Inventor which is the retail version of the Spike Prime (Spike Prime being the edu version).

Is EV3 being retired? ›

For those paying attention, the move isn't necessarily a surprise: when the company retired its Mindstorms EV3 system last year, it pointed customers towards its Lego Education Spike kit rather than the Mindstorms Robot Inventor kit that was also available.

Is Lego EV3 retired? ›

The LEGO MINDSTORMS EV3 Programmer app will be removed from current app stores at the end of June 2021. The retired LEGO MINDSTORMS EV3 Home Edition software for Mac and PC (Labview) can be found further down. Please notice this software is no longer supported by the LEGO Group.

What are the four ways to control your EV3 robot? ›

There are five buttons to make the robot move forward, backward, turn right, turn left and stop. You can also drag the slider to adjust motor power. Notice: You don't have to write a program for the EV3, just power it on and pair with your Android phone.

What is VAC voice activated commands? ›

VAC (Voice Activated Commands) is an efficient and intuitive software solution aimed to provide you with the means of controlling your applications or games just by speaking the commands, rather than typing them into your keyboard.

What is a voice command device? ›

Voice Command Devices – What are they? a device controlled by means of a voice. removes the need to use buttons, dials and switches, consumers can easily operate appliances without hands or while doing other tasks.

Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 5808

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.