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

eventduino

v0.1.3

Published

Evented Arduino for Node.js

Downloads

5

Readme

EventDuino

An event-driven Arduino to Node.js adapter.

Support is pretty basic so far:

  • Arduino sketch with an event loop
  • Extendable protocol
  • Basic events
  • Reading and writing of pins
  • Watching pins for changes and emitting events

On the Arduino

Compile and upload the sketch in src/eventdu. This sketch listens for commands and watches for changes to pins via the watch command.

The bulk of the sketch is the parser.

Protocol

The protocol is very minimal. It includes a command, up to ten arguments, and optional comments. Total packet size is currently limited to 1024 bytes.

Currently defined commands and responses:

  • INIT - Returned from the Arduino upon init, emits init

  • ERROR - Returned from the Arduino upon error, emits exception

  • PING - Sends a ping packet to the Arduino

  • PONG - Returned from the Arduino from a ping, emits pong

  • GET - Send and receive, emits get, arguments are the pin and the value

  • SET - Sends a set packet, arguments are the pin and the value

  • WATCH - Tells the Arduino to watch for a change on a pin, emits watch with apin and value on change

  • UNWATCH - Tells the Arduino to stop watching for a change on a pin

  • OK - Ok!

    <packet> ::= <command> <argument> <comment> <EOL>

    ::= [0-9a-zA-Z][0-9a-zA-Z]

    ::= | [0-9]+ ':' [0-9a-zA-Z]+ |

    ::= | '#' [0-9a-zA-Z]+

Basic Events

The event system is pretty straightforward. On initialization an init event is emitted, at which point further commands can executed.

var eventduino = require('eventduino');

var ardy = new eventduino({ serialport: '/dev/tty.usbmodemfa131' });

ardy.on('pong', function () {
  console.log("PONG!");
});

ardy.on('init', function (args, comment) {
  console.log('Eventduino init version ' + comment);
  ardy.ping();
});

Getting and Setting

Getting and setting of pins is very simple. The pin mode is changed automatically.

var eventduino = require('eventduino');

var ardy = new eventduino({ serialport: '/dev/tty.usbmodemfa131' });

ardy.on('get', function (args) {
  console.log("pin " + args[0] + " is set to " + args[1]);
});

ardy.on('init', function (args, comment) {
  console.log('Eventduino init version ' + comment);

  // get the value of pin 1
  ardy.get(1);

  // set the LED pin to HIGH (1)
  ardy.set(13, 1);
});

Watching for Changes

Eventduino can be set into watch mode, which will check for any changes to the pin and send a command if one occurs. A watch can be setup on as many pins as required.

var eventduino = require('eventduino');

var ardy = new eventduino({ serialport: '/dev/tty.usbmodemfa131' });

ardy.on('watch', function (args) {
  console.log("pin " + args[0] + " is now set to " + args[1]);
  
  // stop watching pin 5 on first change
  if (args[0] === 5) {
    ardy.unwatch(5);
    ardy.set(13, 1);
  }
});

ardy.on('init', function (args, comment) {
  console.log('Eventduino init version ' + comment);

  ardy.watch(1);
  ardy.watch(5);
});

TODO

Implement analog pins.