Microduino Intelligent Music Box

From Microduino Wiki
Jump to: navigation, search

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
Intelligent music.jpg

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.
IPodtouch steup-1.jpg
  • Step 2: Fixate OLED on the panel
IPodtouch steup-2.jpg
  • Step 3: Make holes for the operation of USB power supply, music change and button control.
IPodtouch steup-3.jpg

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.
IPodtouch Module steup-1.jpg
  • Step 2: Put the storage card on Audio-KEY-SD
IPodtouch Module steup-2.jpg
  • Step 3: Stack Microduino-Audio on the music box by facing the side with a hole.
IPodtouch Module steup-3.jpg
  • Step 4: Download program for the core board by stacking core+ and USBTTL.
IPodtouch Module steup-4.jpg
  • 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.
IPodtouch Module steup-5.jpg
  • After that, put the whole stacked boards into the box.
IPodtouch Module steup-6.jpg
  • Step 8: Next, wield the two loudspeakers to Microduino-Amplifier through wire and then stack the system on the side with Audio module.
IPodtouch Module steup-7.jpg
  • Step 9: Connect DUO-V and OLED.
IPodtouch Module steup-8.jpg
  • At last, close the box and get ready to test.
IPodtouch Module steup-9.jpg

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.

Music steup-1.jpg
  • 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.)
Music steup-2.jpg

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.
Audio-KEY-SD ctrl -1.jpg
  • Step 2: If the time goes wrong, please enter “Set Clock” and set the right time.
Audio-KEY-SD ctrl -2.jpg
Audio-KEY-SD ctrl -3.jpg
  • 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.
Audio-KEY-SD ctrl -4.jpg
  • Step 4: Enter “Set Alarm”, you can set the alarm.
Audio-KEY-SD ctrl -5.jpg
  • Step 5: You can set font size by entering “System”.
Audio-KEY-SD ctrl -6.jpg

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.

Ble-Connection- Microduino.png
Ble-Connection-new.png

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”.

Ble- Characteristic-0.png
Ble- Characteristic.png

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

Ble- HEX.png
Ble- UTF-8 String.png

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

Ble- Write.png
Ble- Write-1.png
Ble-Write-1.png

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