master
louisa 2 years ago
parent e1d05dfeb5
commit 2b49b08931

@ -10,7 +10,6 @@ var port = 8000;
const { SerialPort } = require('serialport') const { SerialPort } = require('serialport')
const { ReadlineParser } = require('@serialport/parser-readline') const { ReadlineParser } = require('@serialport/parser-readline')
const sport = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 }) const sport = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
const parser = sport.pipe(new ReadlineParser({ delimiter: '\r\n' })) const parser = sport.pipe(new ReadlineParser({ delimiter: '\r\n' }))
parser.on('data', console.log) parser.on('data', console.log)

@ -18,11 +18,9 @@
// Split the data into separate parts // Split the data into separate parts
const [node, value] = data.split(' '); const [node, value] = data.split(' ');
if (node === 'node3' && value === '15'){
if (node === 'node4' && value === '21') { document.body.style.backgroundColor = 'red';}
// Change the background color to red else {
document.body.style.backgroundColor = 'red';
} else {
// Restore the default background color // Restore the default background color
document.body.style.backgroundColor = 'white'; document.body.style.backgroundColor = 'white';
} }

Loading…
Cancel
Save