Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
StandardFirmataBLE test for RedBearLab BLE Nano
/*
* NOTE: This will not run without modification until this issue is resolved:
* https://github.com/RedBearLab/nRF51822-Arduino/pull/97.
*
* Until then, you will need to patch the RedBearLab nRF51822-Arduino core
* library by following these instructions:
* 1. Install v1.0.7 of the RedBear nRF51822 Boards package using the Arduino
* Boards Manager (Tools > Boards > Boards Manager...). If you have a newer
* version already installed, first downgrade to v1.0.7.
* 2. Clone https://github.com/soundanalogous/nRF51822-Arduino and checkout the
* stream-fix branch.
* 3. From the cloned repo, copy the contents of the RBL_nRF51822 directory to
* the /1.0.7/ directory in the /RedBear/hardware/nRF51822/ package that was
* installed via the Arduino Board Manager. On OS X this is located in:
* ~/Library/Arduino15/packages/
* 4. Copy StandardFirmataBLE and uncomment the 5 line #ifdef BLE_NANO block in
* bleConfig.h (File > Examples > Firmata > StandardFirmataBLE)
* 5. Compile and upload your copy of StandardFirmataBLE to the BLE Nano
*
* To run with logging run as:
* DEBUG=ble-serial node ble-nano-test
*
* To run, install the following modules:
* npm install ble-serial
* npm install firmata
*/
var BLESerialPort = require('ble-serial').SerialPort;
var Firmata = require('firmata').Board;
// use the virtual serial port to send a command to a firmata device
var board = new Firmata(new BLESerialPort());
board.on("ready", function() {
console.log(
board.firmware.name + "-" +
board.firmware.version.major + "." +
board.firmware.version.minor
);
var state = 1;
var blinkPin = 13;
setInterval(function() {
board.digitalWrite(blinkPin, (state ^= 1));
}, 2500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment