Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ble-firmata

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ble-firmata

BlendMicro & Arduino BLE-Shield Firmata implementation for Node.js

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

BLE Firmata

Arduino Firmata implementation on BLE (Bluetooth Low Energy) and Node.js.

Build Status

  • Firmata is a protocol to controll Arduino from software on PC.
    • You can embed Arduino code into Node.js application.
  • supports BlendMicro.
    • also should works on BLE Shield, but I dont't have it.

sites

Install

% npm install ble-firmata

Requirements

Usage

Samples

Setup

Connect

var BLEFirmata = require('ble-firmata');
var arduino = new BLEFirmata();

// search device with BLE peripheral name
arduino.connect("BlendMicro");

// search with default name "BlendMicro"
arduino.connect();

arduino.on('connect', function(){

  console.log("board version"+arduino.boardVersion);
  // your-code-here

});

Reset

arduino.reset(callback);

Close

arduino.close(callback);

I/O

Digital Write

arduino.digitalWrite(13, true, callback);
arduino.digitalWrite(13, false, callback);

Digital Read

arduino.pinMode(1, BLEFirmata.INPUT);
console.log( arduino.digitalRead(1) ); // => true/false

Digital Read (event)

arduino.pinMode(1, BLEFirmata.INPUT);

arduino.on('digitalChange', function(e){
  console.log("pin" + e.pin + " : " + e.old_value + " -> " + e.value);
});

Analog Write (PWM)

setInterval(function(){
  var an = Math.random()*255; // 0 ~ 255
  arduino.analogWrite(9, an, callback);
}, 100);

Analog Read

console.log( arduino.analogRead(0) ); // => 0 ~ 1023

Analog Read (event)

arduino.on('analogChange', function(e){
  console.log("pin" + e.pin + " : " + e.old_value + " -> " + e.value);
});

Servo Motor

setInterval(function(){
  var angle = Math.random()*180; // 0 ~ 180
  arduino.servoWrite(11, angle, callback);
}, 1000);

Sysex

Send

arduino.sysex(0x01, [13, 5, 2], callback);  // command, data_array, callback

Register Sysex Event

arduino.on('sysex', function(e){
  console.log("command : " + e.command);
  console.log(e.data);
});

Debug

set DEBUG env var

% DEBUG=ble-firmata node samples/analog_write.js
% DEBUG=*ble* node samples/analog_write.js

Test

Install SysexLedBlinkFirmata into Arduino

Run Test

% npm install
% npm test

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Keywords

FAQs

Package last updated on 09 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc