long readVoltage(int)
Reads the analog voltage for the specified pin.
Parameters
Name | Description |
index |
int The index of the pin to read. |
Return
The analog voltage value between 0 and 1023 where 0 equals 0 volts and 1023 is the highest possible voltage value for the device.
Remarks
The pin value must be between 1 and 7. A return value of 0 equals 0 volts. A return value of 1023 equals the devices highest possible voltage.
Examples
function readAdc() {
if (!KioGPIOBoard.isOpen()) return;
var adcInd = document.getElementById('adcInd');
var readRes = document.getElementById('readRes');
var voltInt = KioGPIOBoard.readVoltage(parseInt(adcInd.value));
var voltage = 3.3 * voltInt / 1023;
readRes.innerHTML = voltage + 'V';
}
Requirements
KioWare for Android version 3.22 or greater.