Skip to content

Commit dd7c08a

Browse files
ni-ctjanson
authored andcommitted
Added IR Remote support
1 parent fb115ef commit dd7c08a

18 files changed

Lines changed: 3123 additions & 3 deletions

File tree

examples/ir.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var arduino = require('../')
2+
var arduino = require('../')
3+
board, ir;
4+
5+
var board = new arduino.Board({
6+
debug: true
7+
});
8+
9+
var ir = new arduino.IR({
10+
board: board
11+
});
12+
13+
board.on('ready', function(){
14+
setTimeout(function() {
15+
//ir.send(3, "20DF10EF", 48);
16+
ir.send(7, "802080A0", "C2CA");
17+
}, 1000);
18+
});

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
Ping: require('./lib/ping'),
1010
PIR: require('./lib/pir'),
1111
LCD: require('./lib/lcd'),
12-
RC: require('./lib/rc')
12+
RC: require('./lib/rc'),
13+
IR: require('./lib/ir')
1314
};

lib/ir.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Main IR constructor
3+
* Process options
4+
* Tell the board to set it up
5+
*/
6+
var IR = function (options) {
7+
if (!options || !options.board) throw new Error('Must supply required options to IR');
8+
this.board = options.board;
9+
}
10+
11+
/*
12+
* Send IR code
13+
* types:
14+
* 1 RC5
15+
* 2 RC6
16+
* 3 NEC
17+
* 4 Sony
18+
* 5 DISH
19+
* 6 Sharp
20+
* 7 Panasonic
21+
* 8 JVC
22+
*/
23+
IR.prototype.send = function (type, val, len) {
24+
len = len + '';
25+
for (var i = len.length; i < 4; i++) {
26+
len = '0' + len;
27+
};
28+
var msg = '9500' + type + val + len;
29+
this.board.write(msg);
30+
}
31+
32+
module.exports = IR;

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"author": "Cam Pedersen <diffference@gmail.com> (http://campedersen.com/)",
2+
"author": {
3+
"name": "Cam Pedersen",
4+
"email": "diffference@gmail.com",
5+
"url": "http://campedersen.com/"
6+
},
37
"contributors": [
48
{ "name": "Rick Waldron", "email": "waldron.rick@gmail.com" },
59
{ "name": "Leonhardt Wille", "email": "wille@riverlabs.de" },
@@ -12,7 +16,7 @@
1216
],
1317
"name": "duino",
1418
"description": "Arduino framework for mad scientists",
15-
"version": "0.0.10",
19+
"version": "0.0.11",
1620
"keywords": [
1721
"arduino",
1822
"serial",

0 commit comments

Comments
 (0)