Skip to content

Commit

Permalink
added ability to turn led on/off with sound
Browse files Browse the repository at this point in the history
  • Loading branch information
VoltVisionFrenchy committed Dec 3, 2013
1 parent 88ed74d commit 2f74558
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sound.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var spawn = require('child_process').spawn;
bbb = require('bonescript');
bbb.pinMode('P9_42', bbb.OUTPUT);

var Sound = function (config) {
config = config || {};
Expand All @@ -10,8 +12,9 @@ var Sound = function (config) {
Sound.prototype.play = function() {
if(this.mockPlay !== true){
// play = spawn('play', ['-q', this.path]);
play = spawn('aplay', ['-q', '/home/root/audio/wolfhowl.wav']);
play = spawn('aplay', ['-q', '/home/root/audio/fox2-short.wav']);
console.log('Playing!!!!!', this.path);
bbb.digitalWrite('P9_42', bbb.HIGH);

play.stdout.on('data', function (data) {
console.log('stdout: ' + data);
Expand All @@ -20,6 +23,7 @@ Sound.prototype.play = function() {

play.on('close', function (code) {
console.log('child process exited with code ' + code);
bbb.digitalWrite('P9_42', bbb.LOW);
});

if (process.pid) {
Expand Down

0 comments on commit 2f74558

Please sign in to comment.