Coder Social home page Coder Social logo

mbwhite / node_mpr121 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adafruit/node_mpr121

0.0 1.0 0.0 12 KB

Access a MPR121 breakout using Node.js from a Raspberry Pi or BeagleBone Black.

Home Page: https://www.adafruit.com/product/2024

License: MIT License

JavaScript 100.00%

node_mpr121's Introduction

MPR121 Library for Node.js

Access a MPR121 breakout using Node.js from a Raspberry Pi or BeagleBone Black.

Installation

This library requires Node.js v6.0.0 or higher.

$ npm install adafruit-mpr121

Detailed Installation for Raspberry Pi

On a Raspberry Pi configure I2C following these instructions. E.g.

sudo apt-get update
sudo apt full-upgrade -y
sudo apt-get install i2c-tools

Make sure you follow these steps to enable autoloading of I2C Kernel module.

Install Node.js if not yet installed, e.g. to install Node v10:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Reboot for above changes to take affect:

sudo reboot

You can check Node version like this:

node -v
# v10.11.0

To install adafruit-mpr121 in your own Node app:

mkdir myapp
cd myapp
npm init
npm install adafruit-mpr121 --save

To run node in interactive mode on command line:

node

Example code below should now work.

Example

const MPR121 = require('adafruit-mpr121'),
      mpr121  = new MPR121(0x5A, 1);

// listen for touch events
mpr121.on('touch', (pin) => console.log(`pin ${pin} touched`));

// listen for release events
mpr121.on('release', (pin) => console.log(`pin ${pin} released`));

// listen for changes to the state of a specific pin
mpr121.on(3, (state) => console.log(`pin 3 is ${state ? 'touched' : 'released'}`));

// check the current state of a specific pin synchronously
const state = mpr121.isTouched(2);
console.log(`pin 2 is ${state ? 'touched' : 'released'}`);

License

Copyright (c) 2016 Adafruit Industries. Licensed under the MIT license.

node_mpr121's People

Contributors

toddtreece avatar ladyada avatar robmckinnon avatar imjustchew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.