Outline
Let's make a remote controlled karaoke machine, which can be controlled to play different songs by IR remote control.
Suitable kits: mCookie202, mCookie302, IBC
Module Bill
Module
Other Equipment
- USB cable*1
- Sensor cable*2
- IR remote control
- Sensor shell*1
- Lego or other fixation structure
Module Setup
Look at the New Sensors
- IR Receiver
- It can receive the external infrared signal, as well as the signal emitted by IR remote control.
- IR remote control
- If you have installed an "IR receiver" on your application, you can use remote control to control it.
- Assemble modules and sensors:
- Stick the red core module, battery base and green extension module together;
- Connect the buzzer to pin 8/9 of Hub;
- Connect the IR receiver to pin 4/5 of Hub;
- Insert one end of USB into the USB upload module, and connect the other to computer;
Programming
Required Program Blocks
Programming Thought
Detect whether there was IR signal received. If signal of button A, B and C was received, it will play the corresponding song. After that, IR receiver is enabled, waiting for the next receipt.
Start to Program
IR remote controlled karaoke machine
Save the command code received by the IR receiver of pin 4 in variable ir_code.
Fill in the if program block according to the command code of remote control A, B and C written before, and play different songs according to different codes.
After that, enable the IR receiver of pin 4.
Test the result
After upload, press button A, B and C of the remote control toward the IR receiver, and it will play different songs. Only after a song is played completely and the IR receiver is enabled can the next song be played.
Technical Specification
- The product number of IR Receiver:
- For details about IR receiver, please refer to Sensor-IR Receiver.
Related Cases
FAQ
- Q: Why does the buzzer not buzz when connect directly to the power supply?
- A: Because the buzzer is passive, only changed voltage signal can make it buzz. The active buzzer can buzz if only it is connected to the power supply.
- Q: Can the buzzer sing songs?
- A: It can produce tunes do, re, mi, fa, sol, la, si of different frequency, which can make up songs. Please refer to Music Painting. If you want to play the music, you are supposed to have an audio decoding ship and a horn.
- Q: Why can't we select the songs when it is playing music?
- A: Because the "Buzzer on-song" program block has integrated the code, it has internal delay. Only after it has executed the song can it execute other control command.
|