Created
December 3, 2013 07:11
-
-
Save natevw/7765186 to your computer and use it in GitHub Desktop.
Demo of using https://github.com/natevw/node-rf24 to pongpack to e.g. https://github.com/stanleyseow/RF24/blob/master/examples/pingpair/pingpair.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://gist.github.com/natevw/5789019 for pins | |
var NRF24 = require("./index"), | |
spiDev = "/dev/spidev0.0", | |
cePin = 24, irqPin = 25, //var ce = require("./gpio").connect(cePin) | |
pipes = [0xF0F0F0F0E1, 0xF0F0F0F0D2]; | |
var nrf = NRF24.connect(spiDev, cePin, irqPin); | |
nrf.channel(0x4c).transmitPower('PA_MAX').dataRate('1Mbps').crcBytes(2).autoRetransmit({count:15, delay:500}).begin(function () { | |
var rx = nrf.openPipe('rx', pipes[0]), | |
tx = nrf.openPipe('tx', pipes[1]); | |
rx.on('data', function (d) { | |
console.log("Got data, will respond", d.readUInt32BE(0)); | |
tx.write(d); | |
}); | |
tx.on('error', function (e) { | |
console.warn("Error sending reply.", e); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment