Fork me on GitHub
beagleboard.org

BoneScript

You might be able to see a newer version of this on beagleboard.org/support/bonescript/analogRead

analogRead(pin, [callback])

Read the voltage at an analog input pin.

Arguments

Return value

  • Number from 0 to 1 where 0 is 0V and 1 is the maximum input voltage (1.8V)

callback(x)

  • x.value: return value
  • x.err: error status message

Example

var b = require('bonescript');
b.analogRead('P9_36', printStatus);
function printStatus(x) {
    console.log('x.value = ' + x.value);
    console.log('x.err = ' + x.err);
}

Build and execute instructions

  • Apply voltage between 0V and 1.8V to P9_36 and run the example code.
  • Adjust the voltage between 0V and 1.8V to P9_36 and run the example code again.
  • Alter the code to look at inputs on other analog input pins.

See also

Topics

Related functions

Examples