Playing sounds on the Lego speaker
Although the Lego Brick speaker is not a fully featured stereo media hifi set, it is still a very good tool to make a robot more enjoyable to use. You can play music notes or tones defined by frequency and length on this speaker. You can even play simple melodies. This lecture explains how you can use the speaker in your robot, it also gives an insight on what does the term frequency mean. |
|
Requirements
- Lego Mindstorms EV3 Brick
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Connect Brick via Bluetooth: http://www.ozeki.hu/index.php?owpn=6065
- Lego connection installed: http://www.ozeki.hu/index.php?owpn=6067
Video tutorial: 'How to use the Lego speaker in Ozeki 10'
Start Control Panel through any browser!
If the Brick is effectively paired with your machine through Bluetooth, you can load the Ozeki 10 GUI through any webbrowser with the server IP and port number. If the Brick is not paired yet, you can find a Bluetooth pairing guide on the page at http://www.ozeki.hu/index.php?owpn=6065. Now you can log in with your user details and start the Control Panel to manage all Brick connections. Even the ones that are not integrated into the Brick, but connected to it with an EV3 cable.
Figure 1 - Start Control Panel through the desktop GUI
Select the Brick's speaker from the list of connections!
In case the Brick is not connected yet to Ozeki 10, you can watch the following guide to add it: http://www.ozeki.hu/index.php?owpn=6067. But if it is already luckily connected, you will see the same Lego devices available as you can see on Figure 2. Please click on 'Speaker_1' to play a few tones on it through the chat interface. The next step will demonstrate how to test it.
Figure 2 - The Control Panel automatically detects the available Lego Mindstorms devices
Use the speaker through chat!
The Ozeki chat is really simple, it has only a blue 'Send' button and you can send any digital content through it with a simple click. On Figure 3 you can see the simplest command you can use, called 'beep'. The table on the bottom of this guide contains some extra commands you can test. For example it has an easter egg music, the Hungarian anthem, which you can listen to. Please type 'help' to see the command list in the chat response of the 'Speaker_1' connection.
Figure 3 - Send 'beep' through chat
Look at the speaker events of the Brick!
It is a good idea to check the event list if you didn't heared the beep, so you can search the problem. The 'Events' tabpage can be found on the top, click on it and you should find the beep event, which looks in a similar way as you can see it on Figure 4. The event contains the time it was sent and the user who has sent it. As an extra it show how the beep was created from different frequencies.
Figure 4 - The 'beep' has been successfuly deployed on the EV3 speaker
The command set of the Brick's speaker in Ozeki 10
These tables contain a few example commands, which are capable to create different tones on your speaker. The messages make your speaker play sounds in different frequencies with a required volume and duration. The commands can be used through chat or from any Ozeki 10 programcode you create. Additionally the commands can be easily routed from other Ozeki connections as well.
Command examples | Description |
---|---|
off | turn off the buzzer |
beep | play sound |
0-100, 250-10000, 0 | volume, sound frequency, duration (in millisec, 0 is endless) |
20 C5 300 | play 'C5' note at 20% volume for 300ms |
Hungarian anthem | play the national anthem of Hungary |
Commands Table - Contains unique speaker commands
Basic commands | Description |
---|---|
help | request the command set |
subscribe | subscribe to device messages |
unsubscribe | unsubscribe from device messages |
subscribers | shows the list of subscribers |
Basic commands Table - General commands for all devices
More information
- The touch sensor and sensor messaging
- Capturing infrared signals using the IR sensor
- How to measure light intensity and how to capture color information
- Using motors and rotary encoders
- Distance measurement, the ultrasonic sensor
- Orientation in space, the gyroscope sensor
- Using the LCD display
- Using indicator leds on the Lego Brick
- Power management and working with the brick battery
- Playing sounds on the Lego speaker