-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.tpl
46 lines (37 loc) · 1.18 KB
/
README.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# adc-pi-gpio [](https://travis-ci.org/xseignard/adcPi) [](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