-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (37 loc) · 956 Bytes
/
index.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
40
/*
Arduino Rx = RFID SOUT
Arduino D2 = RFID Enable
Arduino GND = RFID GND
Arduino 5v = RFID VCC
*/
var j5 = require('johnny-five'),
board = new j5.Board(),
rfid;
//board.on('ready', function() {
// new j5.pin('D2').low();
// sp.open(function () {
// console.log('open');
// sp.on('data', function(data) {
// console.log('data received: ' + data);
// });
// sp.write("ls\n", function(err, results) {
// console.log('err ' + err);
// console.log('results ' + results);
// });
// });
//});
var serialport = require("serialport");
var SerialPort = serialport.SerialPort; // localize object constructor
var sp = new SerialPort("/dev/cu.usbmodemfa141", {
baudrate: 2400
}, false);
sp.open(function () {
console.log('open');
sp.on('data', function(data) {
console.log('data received: ' + data);
});
sp.write("ls\n", function(err, results) {
console.log('err ' + err);
console.log('results ' + results);
});
});