Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/ir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var arduino = require('../')
var arduino = require('../')
board, ir;

var board = new arduino.Board({
debug: true
});

var ir = new arduino.IR({
board: board
});

board.on('ready', function(){
setTimeout(function() {
//ir.send(3, "20DF10EF", 48);
ir.send(7, "802080A0", "C2CA");
}, 1000);
});
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = {
Sensor: require('./lib/sensor'),
Ping: require('./lib/ping'),
PIR: require('./lib/pir'),
LCD: require('./lib/lcd')
LCD: require('./lib/lcd'),
IR: require('./lib/ir')
};
32 changes: 32 additions & 0 deletions lib/ir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Main IR constructor
* Process options
* Tell the board to set it up
*/
var IR = function (options) {
if (!options || !options.board) throw new Error('Must supply required options to IR');
this.board = options.board;
}

/*
* Send IR code
* types:
* 1 RC5
* 2 RC6
* 3 NEC
* 4 Sony
* 5 DISH
* 6 Sharp
* 7 Panasonic
* 8 JVC
*/
IR.prototype.send = function (type, val, len) {
len = len + '';
for (var i = len.length; i < 4; i++) {
len = '0' + len;
};
var msg = '9500' + type + val + len;
this.board.write(msg);
}

module.exports = IR;
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"author": "Cam Pedersen <diffference@gmail.com> (http://campedersen.com/)",
"author": {
"name": "Cam Pedersen",
"email": "diffference@gmail.com",
"url": "http://campedersen.com/"
},
"contributors": [
{ "name": "Rick Waldron", "email": "waldron.rick@gmail.com" },
{ "name": "Leonhardt Wille", "email": "wille@riverlabs.de" },
Expand All @@ -10,7 +14,7 @@
],
"name": "duino",
"description": "Arduino framework for mad scientists",
"version": "0.0.9",
"version": "0.0.11",
"keywords": [
"arduino",
"serial",
Expand Down
Loading