# adc-pi-gpio

> Using an ADC with a Pi

Latest version **0.0.2** (published 2013-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install adc-pi-gpio
pnpm add adc-pi-gpio
yarn add adc-pi-gpio
bun add adc-pi-gpio
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2013-08-06 |
| First published | 2013-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Xavier Seignard |
| Maintainers | xavier.seignard |
| Keywords | gpio, pi-gpio, raspberry, pi, adc |

## Links

- npm: https://www.npmjs.com/package/adc-pi-gpio
- Repository: https://github.com/xseignard/adcPi
- Issues: https://github.com/xseignard/adcPi/issues
- npm.io page: https://npm.io/package/adc-pi-gpio

## Dependencies (3)

- [async](https://npm.io/package/async.md) ~0.2.9
- [pi-gpio](https://npm.io/package/pi-gpio.md) ~0.0.2
- [underscore](https://npm.io/package/underscore.md) ~1.5.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2013-08-06
- 0.0.1 — 2013-06-24

## README

# adc-pi-gpio [![Build Status](https://travis-ci.org/xseignard/adcPi.png?branch=master)](https://travis-ci.org/xseignard/adcPi) [![Dependency Status](https://gemnasium.com/xseignard/adcPi.png)](https://gemnasium.com/xseignard/adcPi)

Node.js [Bit banging](http://en.wikipedia.org/wiki/Bit_banging) communication between ADC and the Raspberry Pi.

Largely inspired by ladyada's script: [https://gist.github.com/ladyada/3151375](https://gist.github.com/ladyada/3151375).

## Usage
- install with `npm install adc-pi-gpio --save` 
- check the demo sample:

```js
var ADC = require('../adc-pi-gpio'),
	config = {
		tolerance : 2,
		interval : 300,
		channels : [ 0 ],
		SPICLK: 12,
		SPIMISO: 16,
		SPIMOSI: 18,
		SPICS: 22
	};

var adc = new ADC(config);

process.on('SIGTERM', function(){
	adc.close();
});
process.on('SIGINT', function(){
	adc.close();
});

adc.init();

adc.on('ready', function() {
    console.log('Pins ready, listening to channel');
});
adc.on('close', function() {
	console.log('ADC terminated');
	process.exit();
});
adc.on('change', function(data) {
    console.log('Channel ' + data.channel + ' value is now ' + data.value + ' which in proportion is: ' + data.percent);
});
```
## API

  - [ADC()](#adc)
  - [ADC.init()](#adcinit)
  - [ADC.close()](#adcclose)
  - [ADC.read())](#adcreadchannelnumbercallbackfunction)

## ADC()

  ADC class, that represents an instance of an ADC. 
  
  Below is a code snippet that shows the configuration possibilities. 
  
  The opts object is optional. And each key inside it too.
  
  The values shown there are the defaults fallback.
  
```js
var ADC = require('adc-pi-gpio'),
  opts = {
    tolerance : 2,
    interval : 300,
    channels : [0],
    SPICLK: 12,
    SPIMISO: 16,
    SPIMOSI: 18,
    SPICS: 22
  };
var adc = new ADC(opts);
```

## ADC.init()

  Init the pins that are used by the ADC and start reading on the defined ADC channels.

## ADC.close()

  Close the pins used by the ADC.

## ADC.read(channel:Number, callback:function())

  Read the value of the given ADC channel.

---
_Source: https://npm.io/package/adc-pi-gpio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
