MPR 121

 MPR 121

         The MPR121 is the second generation capacitive touch sensor controller.Its working is like the capacitor's working principle.This module has twelve electrodes points, it communicates via I2C protocol.In those points we can connect any conductive materials.The conductive materials means nothing it like a metal which conduct electricity.We can interface the MPR 121 with arduino to turn ON\OFF the LED or any other.


Application:

  • It is used in MP3 Players,Remote Controls,Mobile Phones.
  • It is also used in PC Peripherals and Lighting Controls.

Sample Project With Arduino:

                                     In this we going to turn ON and OFF the LED whenever the touch in electrode point is detected by MPR 121 sensor.

Materials required:

  • MPR 121
  • Arduino UNO
  • LED 
  • 220 ohm resister
  • Jumper wire
  • Bread board

Circuit:


Code:       

#include <MPR121.h>

#include <Wire.h>

 

#define numElectrodes 2

 

#define LEDPIN 3

 

void setup()

{

  Serial.begin(115200);

  Serial.println("System started");

  pinMode(LEDPIN, OUTPUT);

 

  Wire.begin();

 

  // 0x5C is the MPR121 I2C address on the Bare Touch Board

  if (!MPR121.begin(0x5A)) {

    Serial.println("error setting up MPR121");

    switch (MPR121.getError()) {

      case NO_ERROR:

        Serial.println("no error");

        break;

      case ADDRESS_UNKNOWN:

        Serial.println("incorrect address");

        break;

      case READBACK_FAIL:

        Serial.println("readback failure");

        break;

      case OVERCURRENT_FLAG:

        Serial.println("overcurrent on REXT pin");

        break;

      case OUT_OF_RANGE:

        Serial.println("electrode out of range");

        break;

      case NOT_INITED:

        Serial.println("not initialised");

        break;

      default:

        Serial.println("unknown error");

        break;

    }

    while (1);

  }

 

 

  MPR121.setInterruptPin(4);

  MPR121.setTouchThreshold(40);

  MPR121.setReleaseThreshold(20);

  MPR121.updateTouchData();

}

 

void loop()

{

  if (MPR121.touchStatusChanged()) {

    MPR121.updateTouchData();

    for (int i = 0; i < numElectrodes; i++) {

      if (MPR121.isNewTouch(i)) {

        if (i == 0) {

          digitalWrite(LEDPIN, HIGH);

        }

 

      } else if (MPR121.isNewRelease(i)) {

        if (i == 1) {

          digitalWrite(LEDPIN, LOW);

        }

      }

    }

  }

}


Comments

Popular posts from this blog

Voice Record & Playback Module

GSM Sim800L

GPS