GithubHelp home page GithubHelp logo

isabella232 / webjack-firmata Goto Github PK

View Code? Open in Web Editor NEW

This project forked from publiclab/webjack-firmata

0.0 0.0 0.0 521 KB

A wrapper for WebJack to use as transport layer for firmata.js, for firmata access to an Arduino from a web browser.

Home Page: https://publiclab.github.io/webjack-firmata/example/

License: GNU General Public License v3.0

JavaScript 72.79% C++ 19.87% CSS 0.96% HTML 6.38%

webjack-firmata's Introduction

WebJack-Firmata

...is a wrapper for WebJack to use as transport layer for firmata.js. WebJackPort is inspired by EtherPort from Rick Waldron.

Live Demos

Try it out here: https://publiclab.github.io/webjack-firmata/example/

Keyboard Bindings

A second example, showing triggering of Arduino pins via keyboard keypresses, is available at https://publiclab.github.io/webjack-firmata/example/keyboard/

Find build instructions for the demo at the end of this page.

Serial communication

A third example implements serial communication via firmata's serialWrite, but depends on StandardFirmataPlus.ino, which has not yet been ported over to be WebJack compatible. This could allow webjack-firmata to act as a serial bridge.

Install

To install on your Arduino, see "Sketches" below.

To install on the browser side, you can use NPM:

npm install --save webjackport

Use

var Firmata = require("firmata").Board;
var WebJackPort = require("webjackport");
var board = new Firmata(new WebJackPort());

board.on("ready", function() {
  console.log("READY!");
  console.log(
    board.firmware.name + "-" +
    board.firmware.version.major + "." +
    board.firmware.version.minor
  );

  var state = 1;

  this.pinMode(13, this.MODES.OUTPUT);

  setInterval(function() {
    this.digitalWrite(13, (state ^= 1));
  }.bind(this), 500);
});

Also take a look at the demo site in the example folder.

Sketches

Three example sketches are provided:

  • SimpleDigitalFirmata
  • ConfigurableFirmata
  • StandardFirmataWebJack

SimpleDigitalFirmata and ConfigurableFirmata are capable of setting and reading digital pins. The first one is implemented with the standard Firmata library, the latter with ConfigureableFirmata.

StandardFirmataWebJack is a modification of the standard Firmata firmware and thus has all its capabilities. Additionally a custom SysEx command is implemented, that reports exactly one analog reading.

All sketches are configured with a 10 millisecond delay in the processing loop. This is due to crosstalk from requests messages. An immediate reply will make it difficult for WebJack to distinguish the crosstalk from the actual reply.

Arduino Create

You can use these sketches in the online Arduino editor at:


Known Issues

Currently, it is required to create the board with additional options:

var opts = {
  reportVersionTimeout: 2500,  // increase if no sound is played after loading the site
  skipCapabilities: true  // we skip this for now, reception via WebJack is not reliable enough
};
var board = new Board(new WebJackPort(), opts);

Audio cables may introduce crosstalk that can lead to reception of sent data. As a result of that, firmata can have difficulties to decode answers correctly. It can help to assign empty handler functions to SysEx requests as workaround:

board.sysexResponse(CAPABILITY_QUERY, function (data){});

##Developers

Help improve Public Lab software!

Building

webjackport.js is built using a Grunt task from the source files in /src/, and the compiled file is saved to /dist/webjackport.js. To build, run grunt build. To watch files for changes, and build whenever they occur, run grunt.

Building the demo

The demos in /example/ are bundled with Webpack. Before executing webpack, do npm install -- and cd example -- since you have to run webpack from inside the example directory. The code in /example/bundle.js, is then compiled from /example/Demo.js.

webjack-firmata's People

Contributors

aliciapaz avatar dependabot-preview[bot] avatar dependabot[bot] avatar jywarren avatar rmeister avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.