Difference between revisions of "Music Box (X02)"

From Microduino Wiki
Jump to: navigation, search
(Program)
(Program)
Line 51: Line 51:
 
*Go to '''Tools > Port''' and select the available port
 
*Go to '''Tools > Port''' and select the available port
 
4. Upload the program by clicking on the '''right arrow icon''' on the top left of the window. Or under '''Sketch > Upload'''.
 
4. Upload the program by clicking on the '''right arrow icon''' on the top left of the window. Or under '''Sketch > Upload'''.
*If not using the default Core module included in the kits, please follow the '''[[Selecting_board,_processor,_and_port|selecting the board and processor guide]]'''.
+
'''NOTE''': If not using the default Core module included in the kits, please follow the '''[[Selecting_board,_processor,_and_port|selecting the board and processor guide]]'''.
 
==Debugging==
 
==Debugging==
 
*Open the Serial monitor. Information on detecting the the Audio module (successfully or failed) and start / stop playing of music will be outputted.
 
*Open the Serial monitor. Information on detecting the the Audio module (successfully or failed) and start / stop playing of music will be outputted.

Revision as of 16:25, 3 April 2017

File:Music Box Project.jpg
Music Box Project Build

About

This project uses the AudioPro module to decode and play music off of a MicroSD (with the use of the SD module). Three additional buttons are used for Play / Pause Track, Volume Up / Next Track, and Volume Down / Previous Track. A microphone receives sounds levels and outputs the intensity as a simple sound visualizer to a LED Matrix module.

This project was designed for the second generation mCookie Maker kits (202 Advanced and 302 Expert kits).

Required Materials

  • 1 x mCookie Core
  • 1 x mBattery (202/302 Kit)
  • 1 x mCookie Sensor Hub
  • 1 x LED Matrix
  • 1 x Audio Pro Module
  • 1 x MicroSD Module
  • 3 x Touch Button Sensor
  • 1 x Microphone Sensor
  • 1 x Sensor Cable
  • 1 x MicroSD Card
  • 2 x Speaker
  • 1 x MicroUSB Cable

Build

Sound File

  • There should be a MicroSD card and reader included in 202 and 302 kits.
  • Put an MP3 file onto the root of your MicroSD Card with the name a.mp3. This is the file this program looks to play when activated. It can be a sound effect or a song (such as Alan Walker's Fade).
  • It is possible to have multiple sound files. Read the section on #Tweaking to learn about how to change the code to work with more than 1 file.

Assembly

NOTE: When connecting sensor wires, push on the plastic connector and not on the wires. Pushing on the wire can damage them.

  1. Connect a Touch Button to the Sensor Hub on Pin 2/3. This will be the Volume Up / Next Track button.
  2. Connect a Touch Button to the Sensor Hub on Pin 4/5. This will be the Play / Pause button.
  3. Connect a Touch Button to the Sensor Hub on Pin 6/7. This will be the Volume Down / Previous Track button.
  4. Connect a Micrphone Sensor to the Sensor Hub on Pin A6/A7.
  5. Connect the Two Speakers to the Audio Pro Module.
  6. Insert the MicroSD card with the a.mp3 file into the MicroSD Module.
  7. Create two stacks containing:
    1. (Bottom of Stack) MicroSD Module | Audio Pro Module | Sensor Hub (Top of Stack)
    2. (Bottom of Stack) Core | LED Matrix (Top of Stack)
  8. Stack the two stacks onto the mBattery
  9. Plug in the MicroUSB cable to the mBattery to a computer.

Program

1. Connect mCookie Core to the PC with the USB Cable. Open the Microduino IDE.

2. Copy and paste the code below and upload.

3. Select the board, processor and port:

  • Go to Tools > Board and select Microduino/mCookie-Core (328p)
  • Go to Tools > Processor and select Atmega328P16M,5V
  • Go to Tools > Port and select the available port

4. Upload the program by clicking on the right arrow icon on the top left of the window. Or under Sketch > Upload. NOTE: If not using the default Core module included in the kits, please follow the selecting the board and processor guide.

Debugging

  • Open the Serial monitor. Information on detecting the the Audio module (successfully or failed) and start / stop playing of music will be outputted.

Tweaking

Variables can be edited to change the threshold / detection value for various functions to better fine tune to your environment.

DEBUG will enable debugging mode. Which outputs information to the Serial Port.

LED_BRIGHTNESS_* is brightness value of the (R)ed, (G)reen and (B)lue elements in the RGB LED.

  • Adjustable between 0 ~ 255
  • Default is 20

PLAY_ENTIRE_FILE if true, will play the entire MP3 file once the PIR is triggered.

  • Default is false

Usage

Wave your hand in front of the PIR sensor and the MP3 should start playing. (Or it does it randomly...)