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(err,value)

  • value: return value
  • err: error status message

Example

var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
b.digitalRead('P8_19', printStatus);
function printStatus(err,value) {
    console.log('value = ' + value);
    console.log('err = ' + 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