mpr121

0.0.5 • Public • Published

Node_MPR121

Access the MPR121 chipset via node-i2c

Port of Adafruit_Python_MPR121 to node.js. So far tested on a beaglebone-black rev-c. But it should work on other devices as RasberryPi as well.

Example

Showing a simple loop reading the touch status every 0.1ms

// get library
var MPR121 = require('mpr121');
 
// setup sensor device id 0x5A and i2c-bus 1
var touchsensor = new MPR121(0x5A, 1);
 
// initialize sensor, on success start script
if (touchsensor.begin()) {
    // message how to quit
    console.log('Press Ctrl-C to quit.');
 
    // Interval for reading the sonsor
    setInterval(function() {
        // get touch values
        var t = touchsensor.touched();
 
        // prepare some result array
        var ret = [];
 
        // loop through pins
        for (var i = 0; i < 12; i++) {
            // push status into array
            ret.push (touchsensor.is_touched(i));
        }
        
        // return status array
        console.log(ret);
 
    },100);
};
 

Readme

Keywords

none

Package Sidebar

Install

npm i mpr121

Weekly Downloads

0

Version

0.0.5

License

MIT

Last publish

Collaborators

  • dwisk