项目作者: fiskeben

项目描述 :
A node.js module for querying an mcp3008 analog/digital converter.
高级语言: JavaScript
项目地址: git://github.com/fiskeben/mcp3008.js.git
创建时间: 2013-11-17T19:30:19Z
项目社区:https://github.com/fiskeben/mcp3008.js

开源协议:

下载


mcp3008.js

A node.js module for interfacing the MCP3008 analog/digital converter.

The same instance of the module can control all eight channels on the converter.

Installation

  1. $ npm install mcp3008.js

Usage

Here’s a short example:

  1. var Mcp3008 = require('mcp3008.js'),
  2. adc = new Mcp3008(),
  3. channel = 0;
  4. adc.read(channel, function (value) {
  5. doSomethingToValue(value);
  6. });

Interface

Constructor

  1. new Mcp3008([device]);

Device defaults to /dev/spidev0.0.

Reading

  1. instance.read(channel, callback);

This will read the value on channel and send it to callback.

Polling

  1. instance.poll(channel, interval, callback);

This will read the value on channel every interval milliseconds and send it to callback. Use instance.stop(channel) to stop it.

Tear down

  1. instance.close();

This will release the device and stop polling (if any).