Sample Code and Audio Files

The Arduino sketch to operate the clock along with the audio files are all available in a GitHub repository at https://github.com/cyborg5/NeoPixel-Clock. You can click on that link or click the green button below to directly download a ZIP file containing the files. This repository also contains the 3D model of this project in Fusion 360 format as well as STL files for 3D printing the case.

Download the repository and unzip it. Although we will be able to drag and drop files onto the device as it was a USB drive, you have to load the initial set of MP3 files onto the SD card before we upload the software. Insert a formatted SD card into your PC and drag-and-drop all of the files from the "audio_files" onto the SD card. Do not drag the folder itself, just its contents. After the files are copied, safely eject it from your PC and insert it into the Music Maker Wing. It is safer to do this with the power disconnected. After the card is in place, connect a USB cable and plug it into your PC so that you can upload the code. Open the "clock.ino" sketch in your Arduino IDE. Do not upload it immediately because there is some configuration that you have to do first.

There are six tabs for the six files of this program. The first tab is "clock" containing the main program. Below is a partial listing of the beginning of that file. You should edit it to configure which options you have implemented. Use a "0" to disable the particular option or "1" to enable it.

Download: file
/*
 * Talking Musical Neo-Pixel Clock with Infrared, BLE, and Touch Controls
 *    by Chris Young
 *  released to the public domain
 */
//Various options. Set to zero to disable or one to enable.
//Enables Serial Monitor Debugging
#define MY_DEBUG 0

//Enables Bluetooth controls must use Feather M0 BLA if enabled.
//If disabled, can use Feather M0 basic or M0 express
#define USE_BLE 1

//Enables IR controls. Must connect IR receiver to a digital input pin
#define USE_IR 1

//Enables audio output. Requires Music Maker Feather Wing
#define USE_AUDIO 1

//Enables photocell
#define USE_PHOTOCELL 1

//Enables Touch Controls
#define USE_TOUCH 1

//Enable USB drive
#define USE_USB 1

Once you have configured the sketch for the options you have implemented, There is one additional step before you can upload the sketch. On the Arduino IDE under the "Tools-> USB Stack" menu you must select "TinyUSB" as seen in the image below. This enables the ability to drag-and-drop additional MP3 files onto the device as if it was a flash drive. After setting this option go ahead and compile and upload the sketch. If you get compiler errors, it is likely that you have not properly installed one of the required libraries.

 

When the system initializes you should hear a voice say "System Initialized… Right channel test… Left channel test". You should hear the first phrase from both speakers. The other phrases in only one speaker. This will allow you to verify that both speakers are working. If you're using the BLE option, after a few seconds you will hear "BLE initialized".

The clock initializes to 12 noon. The hours are depicted by a set of five blue or cyan colored pixels. Blue pixels indicate a.m. and cyan colored pixels indicate p.m. The minutes are depicted by a red pixel. The seconds are indicated by a moving green pixel. In the next section we will describe how to set the time and configure other options using the voice prompt setup menu.

If you have set USE_USB 1 then once the sketch is uploaded you should also see a new USB drive available on your PC. It will contain all of the MP3 files used by the system. If you ever need to update these files, you can simply drag-and-drop new files onto the drive and they will be used. You probably will not want to change anything except the music files. But if you want to record your own voice prompts or change the chimes you can do that as well. If you have no need of this feature you can disable it by changing the define to USE_USB 0 and re-upload the sketch.

NOTE: If you are using the touch controls, you may need to calibrate them. See the section on "Advanced Configuration" for details on how to do this.
This guide was first published on Jul 30, 2018. It was last updated on Jul 30, 2018. This page (Sample Code and Audio Files) was last updated on Oct 08, 2019.