Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/monteslu/bean-io
Punchthrough LightBlue Bean IO for use with Johnny-five
https://github.com/monteslu/bean-io
Last synced: 15 days ago
JSON representation
Punchthrough LightBlue Bean IO for use with Johnny-five
- Host: GitHub
- URL: https://github.com/monteslu/bean-io
- Owner: monteslu
- Created: 2014-09-08T20:42:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-05T19:39:29.000Z (about 9 years ago)
- Last Synced: 2024-12-27T23:39:30.046Z (about 1 month ago)
- Language: JavaScript
- Size: 180 KB
- Stars: 22
- Watchers: 7
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nodebots - Bean-IO - Five. (Libraries and Plugins / IO Compatibility Plugins)
README
# Bean-io
Bean-io is a Firmata-compatibility IO class for writing node programs that interact with [LightBlue Bean devices](http://punchthrough.com/bean/). Bean-io was built at [IcedDev](http://iceddev.com/)
### 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](https://github.com/jacobrosenthal/arduino/blob/bean/examples/StandardFirmata/StandardFirmata.ino)We recommend you review [Punchthrough's Getting Started guide](http://punchthrough.com/bean/getting-started/) before continuing.
### Linux Instructions
Make sure that libbluetooth-dev and bluez libraries are installed before installing bean-io.
### Blink an Led
The "Hello World" of microcontroller programming:
```js
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](https://github.com/rwaldron/johnny-five/wiki/IO-Plugins) for [Johnny-Five](https://github.com/rwaldron/johnny-five):
```js
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
```js
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 Port | Arduino Pin | Type |
|----------|-------------|------|
|A0|18|Analog/Digital|
|A1|19|AnalogDigital|
|0|6|Digital — Unavailable right now from firmata|
|1|9|Digital — Unavailable right now from firmata|
|2|10|Digital|
|3|11|Digital|
|4|12|Digital|
|5|13|Digital|