add basic node to arduino communication

This commit is contained in:
Shannon 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: case 126:
if(on) { if(on) {
controlRCOutlets("0FFF0FFF0000"); controlRCOutlets("0FFF0FFF0000");
Serial.println("Light is off.");
on = false; on = false;
} else { } else {
controlRCOutlets("0FFF0FFF000F"); controlRCOutlets("0FFF0FFF000F");
Serial.println("Light is on.");
on = true; on = true;
} }
} }

View file

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