Skip to content

dwisk/Node_MPR121

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
};

About

Access the MPR121 chipset via node-i2c

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published