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

bot-io

v1.0.2

Published

ADC, GPIO, PWM, UARTs, and more on the BeagleBone Black.

Downloads

9

Readme

bot-io

ADC, GPIO, PWM, UARTs, and more with Node.js on the BeagleBone Black.

Features

  • LEDs - Light Emitting Diodes
  • Buttons and Switches
  • ADC - Analog to Digital Conversion
  • GPIO - General Purpose Input Output
  • PWM - Pulse Width Modulation
  • UART - Serial Communication

Installation

$ npm install bot-io

News & Updates

bot-io v1.0.0 - March 28th 2016

bot-io v1.0.0 dropped support for the 3.8.x kernel and added support for the 4.1.x-ti kernel. bot-io v0.1.1 was the last version of bot-io that supported the 3.8.x kernel. All versions of bot-io require cape manager support.

For further information about breaking changes introduced with v1.0.0 see Migrating from bot-io v0.1.1 to v1.0.0

Note that cape_universal should be disabled when using bot-io. This can be achieved by editing /boot/uEnv.txt and modifing the following line

cmdline=coherent_pool=1M quiet cape_universal=enable

to

cmdline=coherent_pool=1M quiet

Usage

LEDs

Let's start off with something simple that doesn't require any hadrware other than the BeagleBone Black itself. The following example will blink onboard user LED0 at a frequency of 1Hz.

var bot = require('bot-io'),
  led0 = new bot.Led(bot.Led.USR0);

led0.once('ready', function () {
  // Blink at 1Hz. Period = 1000ms, on for 500ms, off for 500ms.
  led0.blink();
});

The next example heartbeats all four onboard user LEDs at 100Hz.

var bot = require('../'),
  Led = bot.Led,
  leds;

leds = [Led.USR0, Led.USR1, Led.USR2, Led.USR3].map(function (usrledName) {
  return new Led(usrledName);
});

bot.once('ready', leds, function () {
  leds.forEach(function (led) {
    led.heartbeat();
  });
});

Buttons

Toggle the state of an LED every time a button is pressed.

var bot = require('bot-io'),
  button = new bot.Button(bot.pins.p9_24),
  led = new bot.Led(bot.pins.p9_26),
  ledState = 0;

button.on('pressed', function () {
  led.value(ledState ^= 1);
});

PWM - Pulse Width Modulation

Fade an LED on and off once per second.

var bot = require('bot-io'),
  led = new bot.Pwm(bot.pins.p9_42);

led.once('ready', function () {
  var period = led.period(),
    duty = 0,
    delta = period / 50;

  (function updateDuty() {
    led.duty(duty);

    duty += delta;

    if (duty < 0 || duty > period) {
      delta = -delta;
      duty += delta;
    }

    setTimeout(updateDuty, 10);
  }());
});

ADC - Analog to Digital Conversion

Determine the ambient light level with an analog ambient light sensor.

var bot = require('bot-io'),
  ain = new bot.Ain(bot.pins.p9_36);

ain.once('ready', function () {
  setInterval(function () {
    console.log('value: ' + ain.value() + ', rawValue: ' + ain.rawValue());
  }, 1000);
});

Documentation

Classes

  • Ain - Analog to Digital Conversion
  • Button - Buttons and Switches
  • Gpio - General Purpose Input Output
  • Led - Light Emitting Diodes
  • Pwm - Pulse Width Modulation
  • Uart - Serial Communication

Objects

Functions

  • once - One Time Listener

Additional Information

Tested on a BeagleBone Black rev. A5C with

  • Debian Jessie 8.3 2016-03-20, Kernel 4.1.18-ti-r53, and Node.js v0.12.12