Microduino Intelligent Music Box

来自Microduino Wikipedia
跳转至: 导航搜索

Outline

  • Project: Microduino smart music box
  • Purpose: You can build a smart music box with Microduino modules, playing music via iPodtouch as well as setting alarm clock.
  • Difficulty: High
  • Time-consuming: Four-hour
  • Maker: Microduino Studio-YLB&&Microduino Studio-PKj

Bill of Material

  • Microduino Equipment
Module Number Function
Microduino-Core+ 1 Core board
Microduino-USBTTL 1 Program download
Microduino-Audio 1 Music storage
Microduino-Amplifier 1 Function
Microduino-RTC 1 Time
Microduino-BT 1 Bluetooth transmission data
Microduino-OLED 1 Display
Microduino-Duo-v 1 Extension for lower height
  • Other Equipment
USB cable 1 Connection
Loudspeaker 2
iPodtouch packing box 1 Frame
Knife 1 Cutting
Glue gun 1 Fixing

Document

[Microduino_Audio_ble]

Buildup

iPodtouch Package Change

  • Step 1: Make sure the size of OLED and cut a hole on the paper of the panel with a size same as the OLED.
  • Step 2: Fixate OLED on the panel
  • Step 3: Make holes for the operation of USB power supply, music change and button control.

Overall Buildup

  • Step 1: Fixate Microduino-DUO-V and two loudspeakers at the bottom of the box. Make sure the USB interface on DUO-V facing the front opening of iPodtouch. Meantime, Connect DUO-V and OLED with a 4pin connector.
  • Step 2: Put the storage card on Audio-KEY-SD
  • Step 3: Stack Microduino-Audio on the music box by facing the side with a hole.
  • Step 4: Download program for the core board by stacking core+ and USBTTL.
  • Step 5: Download all the libraries and programs needed, put the libraries in the library folder of Arduino IDE. If have no Microduino IDE, please refer to: Microduino Getting start


  • Step 6: Re-open Arduino IDE, open the downloaded program, select the right board after compiling and download again. (“Ctrl+U” for program download.)
  • Step 7: After the download, you can get rid of USBTTL and stack Core+, RTC and BT modules together.
  • After that, put the whole stacked boards into the box.
  • Step 8: Next, wield the two loudspeakers to Microduino-Amplifier through wire and then stack the system on the side with Audio module.
  • Step 9: Connect DUO-V and OLED.
  • At last, close the box and get ready to test.

Copy Music

  • Step 1: Connect Audio and your computer with a USB cable and you can see a new disk.

The disk can be treated as a memory card you install on Audio-KEY-SD and Audio is like a card reader.

  • Step 2: Create a new folder in the disk and name it as “01” and then cope music to it. (From 001-099, you can save 99 pieces of music in one folder.)

Power-on Test

Dial Wheel Key Control

Dial wheel key has three functions: Regulate upwards, downwards and press down, just like an old MP3. We can select corresponding menu by regulating upwards and downwards and then confirm by pressing down.

  • Step 1: In the power-on state, the default display includes logo, time and alarm clock.
  • Step 2: If the time goes wrong, please enter “Set Clock” and set the right time.
  • Step 3: Play music, enter “Set Tone” and play music. There are ten pieces of music by default. Users can change according to personal needs.
  • Step 4: Enter “Set Alarm”, you can set the alarm.
  • Step 5: You can set font size by entering “System”.

iPodtouch Control

  • Step 1: Prepare an iphone device and LightBlue downloaded in App store.

Step 2: Set IOS device and start IOS device’s Bluetooth function.

Step 3: Open LightBlue and find “Microduino” in “Peripherals Nearby” and click to connect.

Step 4: LED indicator blinks 100ms every 5s after successful connection and meantime, you can see that on IOS. Slide to the bottom, and select “Characteristic 6”.

Step 6: Click “HEX” on the top right and select “UTF-8 String”.

Step 7: Select “Write new value”, input data you want to send and then choose “Done”/

Program Description

  • Bluetooth control instruction

iPodtouch and BT module transmit data through ble protocol. In the main program, Core+ receives data from Bluetooth and process through analysis and gives different commands to Audio module.

  while (mySerial.available() > 0)  //Judge if there is serial port input   
  {
    comdata += char(mySerial.read()); //Read character 
delay(2);                     //Wait for serial port cache  
  }
  if(comdata=="play")
    audio_play();
  else if(comdata=="stop")
    audio_pause();
  else if(comdata=="up")
    audio_up();
  else if(comdata=="down")
    audio_down();
  else if(comdata=="vol+")
    audio_vol_up();
  else if(comdata=="vol-")
    audio_vol_down();

  comdata = "";
  • Dial wheel key detection

Key detection adopts analog value to judge. Since the return values of up- and down-regulation as well as pressing down, we can tell the state from the value and execute accordingly.

  if (analogRead(A6)>300 && analogRead(A6)<400)
    uiKeyCodeFirst = KEY_NEXT;
  else if (analogRead(A6)>200 && analogRead(A6)<300)
    uiKeyCodeFirst = KEY_PREV;
  else if (analogRead(A6)<100)
    uiKeyCodeFirst = KEY_SELECT;
  else 
    uiKeyCodeFirst = KEY_NONE;

Note

  • Users need to install Microduino hardware support package. If not, you can refer to: Microduino Getting start
  • Microduino-Audio consists of two boards—one is cpu for music play, the other is dial wheel key with memory card base for music storage and simple control.
  • Here, phone control only adopts IOS device to debug. You also need IOS device capable of support Bluetooth 4.0. (iPhone4s and higher, iPod touch 5 and higher, iPad 3 and higher, iPad mini and higher)

If adopting Android device to debug, the system needs to be 4.3 or higher so that it can be communicated with BT module. You also need to download serial port communication assistant to

Video

http://v.youku.com/v_show/id_XODM1MDIxMDg4.html