New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bean-io

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bean-io

Punchthrough LightBlue Bean IO

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

Bean-io

Bean-io is a Firmata-compatibility IO class for writing node programs that interact with LightBlue Bean devices. Bean-io was built at IcedDev

Installation

npm install bean-io

Getting Started

In order to use the bean-io library, you will need to load a special version of Firmata onto your Bean device. Bean Firmata

We recommend you review Punchthrough's Getting Started guide before continuing.

Linux Instructions

Make sure that libbluetooth-dev and bluez libraries are installed before installing bean-io.

The "Hello World" of microcontroller programming:

var beanio = require("bean-io");
var board = new beanio.Board({
  timeout: 30000 //optional - defaults to 30 seconds
  // uuid: 'myUuid' //optional - will use first bean found
});

board.on("ready", function() {
  console.log("CONNECTED");
  this.pinMode(13, this.MODES.OUTPUT);

  var byte = 0;

  // This will "blink" the on board led
  setInterval(function() {
    this.digitalWrite(13, (byte ^= 1));
  }.bind(this), 500);
});

Johnny-Five IO Plugin

Bean-IO can be used as an IO Plugin for Johnny-Five:

var five = require("johnny-five");
var beanio = require("bean-io");
var board = new five.Board({
  io: new beanio.Board()
});

board.on("ready", function() {
  var led = new five.Led({pin: 13});
  led.blink();
});

Use ble-bean and Johnny-Five Api Together

var five = require("johnny-five");
var beanio = require("bean-io");
var boardIO = new beanio.Board({
//    name: "ZAPP" // optional: you can specify a localName otherwise defaults to nearby bean
});

var board = new five.Board({
  io: boardIO
});

board.on("ready", function() {

  var button = new five.Button(12); // button on pin 4

  button.on("down", function() {
    console.log("down");
    boardIO.connectedBean.setColor(new Buffer([0, 64, 64]), function(err){
      console.log('set color on', err);
    });
  });

  button.on("hold", function() {
    console.log("hold");
    boardIO.connectedBean.setColor(new Buffer([0, 0, 0]), function(err){
      console.log('set color off', err);
    });
  });

  button.on("up", function() {
    console.log("up");

  });
});

API

Bean-IO subclasses firmata.js and provides the same API.

Pin Mappings

Bean to Arduino UNO

Bean PortArduino PinType
A018Analog/Digital
A119AnalogDigital
06Digital — Unavailable right now from firmata
19Digital — Unavailable right now from firmata
210Digital
311Digital
412Digital
513Digital

Keywords

FAQs

Package last updated on 05 Nov 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