After finishing the data acquisition part of the project, let's see how to make the MagicHat a little more... magic


To make Arduino Yun speak, I first need an external USB audio card like this one here




Then, I need to install an mp3 player that will play a file stored on SD card. Installing the mp3 player is just a few packages away...


opkg update
 opkg install kmod-sound-core 
 opkg install kmod-usb-audio 
 opkg install madplay


Since the control logic runs on the Atmel side of Arduino Yun, we need to devise a way to launch the player. To send data from Atmel to Linino I disabled the bridge, so now Serial1 is read by NodeJS.

So, the firmware running on Atmel will send out (by calling Serial1.println) a string like


PLAY helloworld.mp3


and NodeJS will launch the mp3 player to play to "helloworld.mp3" file


This can easily achieved using the NodeJS's 'exec'  package


var exec = require('child_process').exec;
exec('/usr/bin/madplay ' + filename);