diff --git a/nodejs/ar-com/rc.js b/nodejs/ar-com/rc.js index af2e486..e4a29b3 100644 --- a/nodejs/ar-com/rc.js +++ b/nodejs/ar-com/rc.js @@ -9,8 +9,8 @@ var RC = function (arduino, pin) { RC.prototype.send = function(tristate) { var str = ''; - for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(tristate.substr(i,2), 16)); } - arduino.write(new Buffer('W' + String.fromCharCode(97 + this.pin) + str,'ascii')); + for(i = 0; i < tristate.length; i+=2) { str += String.fromCharCode(parseInt(tristate.substr(i,2), 16)); } + this.arduino.write(new Buffer('W' + String.fromCharCode(97 + this.pin) + str,'ascii')); } RC.prototype.sendDecimal = function (len, val) { diff --git a/nodejs/routes/index.js b/nodejs/routes/index.js index 8f9dd14..464bd03 100644 --- a/nodejs/routes/index.js +++ b/nodejs/routes/index.js @@ -19,9 +19,9 @@ router.get('/toggleLight', function (req, res) { for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); } arduino.write(new Buffer('Wl' + str,'ascii')); res.send('switch light');*/ - - rc_db.fidn(1, function (error, results, fields) { - rc.send(results[0].on_value); + rc_db.find(1, function (error, results, fields) { + if(error) console.log(error); + rc.send(results[0].on_value); }); res.send('switch light'); });