MClock (X02)
Contents
About
This project uses the Real Time Clock (RTC) module to keep track of time. The time is retrieved from the RTC module and displayed on an OLED module. This project is an adaptation of the MWatch project from the first generation mCookie Maker Kits.
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 Real Time Clock (RTC) Module
- 1x mCookie OLED Module
- 1 x MicroUSB Cable
Build
Assembly
- Stack all three of the modules, mCookie Core, mCookie RTC, and mCookie OLED onto mBattery. Ensure that mCookie OLED is on top of the stack.
- 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.
NUM_SONGS determines the number of tracks the program will access.
SONGS[NUM_SONGS] is an array that contains the tracks the program will access. To add additional track add the track name to the array definition. Ensure that the files are in the MicroSD card. Ensure to update NUM_SONGS with the appropriate number of songs.
- Example 1:
const static int NUM_SONGS = 2;
const String SONGS[NUM_SONGS] = {"a.mp3", "b.mp3"};
- Example 2:
const static int NUM_SONGS = 5;
const String SONGS[NUM_SONGS] = {"a.mp3", "b.mp3", "TrackPi.mp3", "TrackIV.mp3", "Track5.mp3"};
SKIP_TIME determines the time in milliseconds (1000 milliseconds = 1 second) in which to hold down the Volume Up / Skip Track touch button or Volume Down / Previous Track touch button in order to register as a Skip Track or Previous Track.
AMBIENT_THRESHOLD determines the Microphone Sensor sound level which is ignored and is treated as ambient noise. Which means there values under this value will not produce an output to the LED Matrix.
MAX_THRESHOLD determines the Microphone Sensor sound level which is considered the max. This enables better scaling of the LED Matrix brightness output.
Usage
The first track should play automatically on start up. The Microphone picks up the sound levels and outputs them accordingly to the LED Matrix.
Control of the music box is as the following:
- Play / Pause Button - Quick tap will play or pause the current track.
- Volume Up / Skip Track Button - Quick tap to increase volume. Hold for more than 1 second (default) then release to skip track.
- Volume Down / Previous Track Button - Quick tap to decrease volume. Hold for more than 1 second (default) then release to go to previous track.