Skip to content

Commit 2c290eb

Browse files
author
ni-c
committed
Added support for rc-switch
1 parent a99a514 commit 2c290eb

8 files changed

Lines changed: 1039 additions & 18 deletions

File tree

examples/rc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var arduino = require('../')
2+
board, rc;
3+
4+
var board = new arduino.Board({
5+
debug: true
6+
});
7+
8+
var rc = new arduino.RC({
9+
board: board,
10+
pin: "10"
11+
});
12+
13+
board.on('ready', function(){
14+
setTimeout(function() {
15+
rc.triState("0FFF0FFFFF0F");
16+
}, 1000);
17+
setTimeout(function() {
18+
rc.triState("0FFF0FFFFF00");
19+
}, 2000);
20+
});

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ module.exports = {
77
Servo: require('./lib/servo'),
88
Sensor: require('./lib/sensor'),
99
Ping: require('./lib/ping'),
10-
PIR: require('./lib/pir')
10+
PIR: require('./lib/pir'),
11+
RC: require('./lib/rc')
1112
};

lib/board.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ util.inherits(Board, events.EventEmitter);
7272
Board.prototype.detect = function (callback) {
7373
this.log('info', 'attempting to find Arduino board');
7474
var self = this;
75-
child.exec('ls /dev | grep usb', function(err, stdout, stderr){
75+
child.exec('ls /dev | grep ACM', function(err, stdout, stderr){
7676
var usb = stdout.slice(0, -1).split('\n'),
7777
found = false,
7878
err = null,

lib/rc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
/*
3+
* Main RC constructor
4+
* Process options
5+
* Tell the board to set it up
6+
*/
7+
var RC = function (options) {
8+
if (!options || !options.board) throw new Error('Must supply required options to LED');
9+
this.board = options.board;
10+
this.pin = options.pin || 10;
11+
}
12+
13+
/*
14+
* Send triState code
15+
*/
16+
RC.prototype.triState = function (val) {
17+
var msg = '96' + this.pin + val;
18+
this.board.write(msg);
19+
}
20+
21+
module.exports = RC;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"contributors": [
44
{ "name": "Rick Waldron", "email": "waldron.rick@gmail.com" },
55
{ "name": "Leonhardt Wille", "email": "wille@riverlabs.de" },
6-
{ "name": "Seiya Konno", "email": "nulltask@gmail.com" }
6+
{ "name": "Seiya Konno", "email": "nulltask@gmail.com" },
7+
{ "name": "Willi Thiel", "email": "ni-c@ni-c.de" }
78
],
89
"name": "duino",
910
"description": "Arduino framework for mad scientists",
10-
"version": "0.0.7",
11+
"version": "0.0.8",
1112
"keywords": [
1213
"arduino",
1314
"serial",

0 commit comments

Comments
 (0)