Skip to content

Commit 2b35633

Browse files
committed
Blinks red and green LEDs on MSP430 launchpad
1 parent 877da49 commit 2b35633

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

launchPad.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
// From: https://github.com/jamesp/node-nmea
3+
4+
// Need to add exports.serialParsers = m.module.parsers;
5+
// to /usr/local/lib/node_modules/bonescript/serial.js
6+
7+
var b = require('bonescript');
8+
9+
var port = '/dev/ttyO1';
10+
var options = {
11+
baudrate: 9600,
12+
parser: b.serialParsers.readline("\n")
13+
};
14+
15+
b.serialOpen(port, options, onSerial);
16+
17+
18+
function onSerial(x) {
19+
console.log(x.event);
20+
if (x.err) {
21+
console.log('***ERROR*** ' + JSON.stringify(x));
22+
}
23+
if (x.event == 'open') {
24+
console.log('***OPENED***');
25+
setInterval(sendCommand, 1000);
26+
}
27+
if (x.event == 'data') {
28+
console.log(String(x.data));
29+
}
30+
}
31+
32+
var command = ['r', 'R', 'g', 'G'];
33+
var commIdx = 1;
34+
35+
function sendCommand() {
36+
// console.log('Command: ' + command[commIdx]);
37+
b.serialWrite(port, command[commIdx++]);
38+
if(commIdx >= command.length) {
39+
commIdx = 0;
40+
}
41+
}

0 commit comments

Comments
 (0)