add basic node to arduino communication

This commit is contained in:
Stefan Sterz 2016-01-12 20:22:26 +01:00
parent f12026d900
commit 90240c7c39
2 changed files with 12 additions and 0 deletions

View File

@ -21,9 +21,11 @@ void loop()
case 126:
if(on) {
controlRCOutlets("0FFF0FFF0000");
Serial.println("Light is off.");
on = false;
} else {
controlRCOutlets("0FFF0FFF000F");
Serial.println("Light is on.");
on = true;
}
}

View File

@ -1,9 +1,19 @@
var express = require('express');
var router = express.Router();
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("/dev/ttyACM0", {
baudrate: 9600
});
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
app.get('/toggleLight', function (req, res) {
res.send('switch light');
serialport.write(new Buffer(0x7E));
});
module.exports = router;