Last active
September 4, 2017 23:33
-
-
Save soundanalogous/d39bb3eb36333a0906df to your computer and use it in GitHub Desktop.
StandardFirmataBLE test for RedBearLab BLE Nano
This file contains 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
/* | |
* 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