spi support adc 3008
This commit is contained in:
Родитель
5fbe2bbb28
Коммит
ee55bcd616
|
@ -8,7 +8,8 @@
|
|||
"raw-body": "1.x",
|
||||
"cors": "2.4.1",
|
||||
"pi-gpio": "0.0.6",
|
||||
"superagent": "0.18.2"
|
||||
"superagent": "0.18.2",
|
||||
"adc-pi-spi": "0.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "0.10.x"
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
ADC = require ('adc-pi-spi');
|
||||
options = {
|
||||
tolerance: 10,
|
||||
pollInterval: 200,
|
||||
channels: [0, 1, 2, 3]
|
||||
}
|
||||
adc=new ADC('/dev/spidev0.0', options);
|
||||
|
||||
adc.on ('change', function(channel, value){
|
||||
console.log('channel ', channel, 'is now', value);
|
||||
readValues();
|
||||
});
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
adc.close();});
|
||||
|
||||
function readValues() {
|
||||
adc.read(0, function (data) {
|
||||
console.log("value is ----------------------", data);
|
||||
});
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче