diff --git a/arduino/src/sketch.ino b/arduino/src/sketch.ino index b049b2b..3122c5b 100644 --- a/arduino/src/sketch.ino +++ b/arduino/src/sketch.ino @@ -29,10 +29,14 @@ void loop() void decodeMessage() { if(com) { int cmd = message[0]; + Serial.println(cmd); int pin = message[1] - 97; + Serial.println(pin); int val[6]; memcpy(val, message + 2, 6); + for(int i =0;i<6;i++) {Serial.println(val[i]);} + switch (cmd) { //case 80: break; //case 81: break; diff --git a/nodejs/ar-com/arduino.js b/nodejs/ar-com/arduino.js index e08d638..b41b7e0 100644 --- a/nodejs/ar-com/arduino.js +++ b/nodejs/ar-com/arduino.js @@ -37,9 +37,11 @@ Arduino.prototype.setup = function () { self.serial.on('open', function () { setTimeout(function () { self.serial.write(new Buffer('00000000')); + self.serial.write(new Buffer('Z0000000', 'ascii')); self.emit('success'); self.serial.on('data', function(data){ + console.log(data); self.emit('data', data); }); diff --git a/nodejs/routes/index.js b/nodejs/routes/index.js index 223c30c..cd448cf 100644 --- a/nodejs/routes/index.js +++ b/nodejs/routes/index.js @@ -11,7 +11,10 @@ router.get('/', function(req, res, next) { }); router.get('/toggleLight', function (req, res) { - arduino.write(new Buffer('~','ascii')); + var s = "0FFF0FFF000F"; + var str = ""; + for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); } + arduino.write(new Buffer('Wa' + str,'ascii')); res.send('switch light'); });