Fork me on GitHub
beagleboard.org

BoneScript

Demo: SeeedStudio Grove Touch Sensor

The Grove Touch Sensor provides a simple capacitive sensor to detect a finger touch.


Example

var b = require('bonescript');
var previous = b.LOW;
var TOUCH = 'P9_22';
b.pinMode(TOUCH, b.INPUT);
function doRead() {
    b.digitalRead(TOUCH, printStatus);
}
function printStatus(x) {
    if(x.value != previous) {
        if(x.value) {
            console.log('Touched');
        } else {
            console.log('Released');
        }
        previous = x.value;
    }
}
setInterval(doRead, 100);




Build and execute instructions

  • Connect Touch Sensor to UART2 Grove connector on BeagleBone Green.
  • Click "Run" on the code and it will output when the button is touched.

See also

Related functions