npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arduino-firmata

v0.3.4

Published

Arduino Firmata implementation for Node.js

Downloads

130

Readme

arduino-firmata

Arduino Firmata protocol (http://firmata.org) implementation on Node.js.

  • Firmata is a protocol to controll Arduino from software on PC.
  • You can embed Arduino code into Node.js application.
  • Support sharing an Arduino between multiple processes.
  • https://github.com/shokai/node-arduino-firmata
  • https://npmjs.org/package/arduino-firmata

Install

% npm install arduino-firmata

Requirements

  • Arduino (http://arduino.cc)
    • testing with
      • Arduino Diecimila
      • Arduino Duemillanove
      • Arduino UNO
      • Arduino Leonardo
      • Arduino Micro
      • Seeduino v2
  • Arduino Standard Firmata v2.2
    • Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]

Usage

Samples

  • https://github.com/shokai/node-arduino-firmata/tree/master/samples

Setup

Connect

var ArduinoFirmata = require('arduino-firmata');
var arduino = new ArduinoFirmata();

arduino.connect(); // use default arduino
arduino.connect('/dev/tty.usb-device-name');

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(7, ArduinoFirmata.INPUT);
console.log( arduino.digitalRead(7) ); // => true/false

Digital Read (event)

arduino.pinMode(7, ArduinoFirmata.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

  • http://firmata.org/wiki/V2.1ProtocolDetails#Sysex_Message_Format
  • https://github.com/shokai/node-arduino-firmata/tree/master/samples/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);
});

Develop

% npm install
% npm run build
# or
% npm run watch

Test

Install SysexLedBlinkFirmata into Arduino

  • https://github.com/shokai/node-arduino-firmata/blob/master/samples/sysex/StandardFirmataWithLedBlink/StandardFirmataWithLedBlink.ino

Run Test

% 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