This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
trev/nodejs/routes/index.js

22 lines
568 B
JavaScript
Raw Normal View History

2016-01-12 17:49:13 +01:00
var express = require('express');
var router = express.Router();
var Arduino = new require('../ar-com/arduino');
var arduino = new Arduino();
2016-01-14 21:43:45 +01:00
arduino.setup();
/* GET home page. */
2016-01-12 17:49:13 +01:00
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.get('/toggleLight', function (req, res) {
2016-01-18 22:35:01 +01:00
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');
});
2016-01-12 17:49:13 +01:00
module.exports = router;