Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
294a1a1
commit 98bf7c2
Showing
4 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var ADC = require('adc-pi-gpio'), | ||
config = { | ||
tolerance : 2, | ||
interval : 300, | ||
channels : [ 0 ], | ||
//SPICLK: 12, 23, | ||
//SPIMISO: 16, 21, | ||
//SPIMOSI: 18, 19, | ||
//SPICS: 22, 24 | ||
SPICLK: 23, | ||
SPIMISO: 21, | ||
SPIMOSI: 19, | ||
SPICS: 24 | ||
}; | ||
|
||
var adc = new ADC(config); | ||
adc.init(); | ||
|
||
adc.on('ready', function() { | ||
console.log('Pins ready, listening to channel'); | ||
}); | ||
|
||
adc.on('change', function(data) { | ||
//Pressure((((adc+0.3)/255)-0.04)/0.009) | ||
//console.log("caculated", ((((data.value + 0.3) / 255) - 0.04) / 0.009) ); | ||
console.log('Channel ' + data.channel + ' value is now ' + data.value + ' which in proportion is: ' + data.percent); | ||
}); | ||
|
||
//clean up. | ||
adc.on('close', function() { | ||
console.log('ADC terminated'); | ||
process.exit(); | ||
}); | ||
|
||
process.on('SIGTERM', function(){ | ||
adc.close(); | ||
}); | ||
|
||
process.on('SIGINT', function(){ | ||
adc.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters