ADC library
Note Content
Library provides functionality for Analog to Digital converter. Initialize:
var Adc = require('adc');
var adc = new Adc(0,10000);
Adc (channel, interval);
Creates instance of ADC for channel and will automatically measure with interval. Interval can be 0 = no automatic. measure, 100...30000 milliseconds.
Number channel - number of channel.
Number interval - 100...30000 milliseconds. 0 = no periodic. measure.
Read ADC value
getValue ();
Reads actual value of ADC.
Periodically measurement
When new value of ADC is measured, function adcMeasured(...) will be invoked. This function has to be defined in your code.
adcMeasured (values);
Array values - is array which contains all measured values.
Example - Measure ADC values
var Adc = require('adc');
var sys = require('system');
var adc = new Adc(0,10000);
adc.adcMeasured = function(values){
for (i=0;i<values.length;i++){
sys.println("adc:"+i+" "+values[i])
}
}
Release port
Releases an instance of a ADC.
release ();
function releases an instance of ADC.
Example release()
adc.release();