Fork me on GitHub
beagleboard.org

BoneScript

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

digitalRead(pin, [callback])

Read the status of a digital I/O pin.

Arguments

Return value

  • HIGH if pin is HIGH
  • LOW if pin is LOW

callback(x)

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

Example

var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
b.digitalRead('P8_19', printStatus);
function printStatus(x) {
    console.log('x.value = ' + x.value);
    console.log('x.err = ' + x.err);
}

Build and execute instructions

  • Apply 0V to P8_19 and run the example code.
  • Apply 3.3V to P8_19 and run the example code again.
  • Alter the code to look at inputs on other pins.

See also

Topics

Related functions

Examples