Outline
Play your favorite songs with buzzer.
Suitable kits: mCookie102, mCookie202, mCookie302, IBC
Module Bill
Module
Other Equipment
- USB cable*1
- Sensor cable*1
- Lego shell*1
- Lego or other fixation structure
Module Setup
- Assemble the modules and sensors:
- Stick the red core module, USB upload module and extension module;
- Connect the buzzer to pin 6/7 of Hub;
- Insert one end of USB cable into the USB upload module, and connect the other end to computer;
Programming
Required Program Block
Programming Thought
At first, popularize the related knowledge to numbered musical notation-note.
Simulate different notes with buzzer, and control the beats with delay program block, to play the song Twinkle Twinkle Little Star.
Start to Program
1. The first piece of music
Use “Buzzer on” melody program block to set the melody, delaying 500ms representing this note lasting for one beat, delaying 500ms representing this note lasting for two beat.
2. The second piece of music.
Use “Buzzer on” melody program block to set melody, and use delay to select beat.
Test the result
After upload, try it to check whether you can hear the song Twinkle Twinkle Little Star as supposed?
- Q: Why dose the music sound vague, while the program is right, there is no pause between two notes?
- A: We can add a “buzzer off” program block to the end of each note.
Delay 500ms, so that this mote can last for one beat; add “Buzzer off” and “delay” program block to make the note pause for 50ms, separating from the next not.
Test the result
After upload, it is clear between each two notes.
Set up a little music box with Lego, and install buzzer on it, and play your own music with it, then share with your friends.
Technical Specification
- The product number of buzzer:
- The buzzer is passive.
- For details about buzzer, please refer to Sensor-Buzzer.
Related Cases
FAQ
- Q: Why can't the buzzer ring, directly connected to the power supply?
- A: Because the buzzer belongs to passive buzzer, only changed voltage signal can make it ring. It is the active buzzer that can ring after added voltage.
- Q: Can the buzzer sing?
- A: It can emit do, re, mi, fa, sol, la, si of different frequencies, and can make up music, please refer to Music Painting. If you want to play music, audio decoder chip and horn are required.
|