-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (32 loc) · 802 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const { SerialPort } = require('serialport');
const serialport = new SerialPort({
path: 'COM1',
baudRate: 9600,
});
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res)
{
res.sendFile(__dirname + '/index.html');
});
app.use(express.static(__dirname + '/node_modules/createjs-soundjs/lib'));
app.use(express.static(__dirname + '/sfx'));
io.on('connection', function(socket)
{
console.log("It's ASMR time, baby!");
});
http.listen(8080, function()
{
console.log('Hey! Open localhost:8080 in your web browser!');
});
var intensity = 0;
serialport.on('open', function()
{
serialport.on('data', function(data)
{
intensity = 1023 - data;
io.emit('update', intensity);
});
});