21 lines
568 B
JavaScript
21 lines
568 B
JavaScript
var express = require('express');
|
|
var router = express.Router();
|
|
var Arduino = new require('../ar-com/arduino');
|
|
var arduino = new Arduino();
|
|
|
|
arduino.setup();
|
|
|
|
/* GET home page. */
|
|
router.get('/', function(req, res, next) {
|
|
res.render('index', { title: 'Express' });
|
|
});
|
|
|
|
router.get('/toggleLight', function (req, res) {
|
|
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');
|
|
});
|
|
|
|
module.exports = router;
|