Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor

Components and supplies

Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor
Arduino UNO
×1
Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor
Adafruit Capacitive Touch Sensor Breakout - MPR121
×1
Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor
LED (generic)
×1

Apps and online services

Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor
Arduino IDE

About this project

MPR121 is a 12-pin touch sensor, using capacitance capabilities of the IC.

There are 2 libraries for this IC, I personally prefer Using the bare conductive one.

https://github.com/BareConductive/mpr121

The chip has a trigger pin, that allow you to know that one of the pins was either touched or released, giving you great response time and giving you option to use an interrupt instead of scanning the state in the loop – like showed in the example.The only down side it that you have only one trigger pin for all the 12 IO pins of the IC.The I2C address can be set ADDR is the I2C address select pin. By default, this is pulled down to ground with a 100K resistor, for an I2C address of 0x5A. You can also connect it to the 3Vo pin for an address of 0x5B, the SDA pin for 0x5C or SCL for address 0x5DThis setting is for the adafruit boards, some of the clone boards haved ifferent I2C address sets and defaults. You can use the I2C scanner in case you do not know the one for your board.

Connecting the boards is really simple, as shown in the drawing.

One thing do note - most of the breakout boards power supply is rated at 3.3V do not power it with the 5V. what about the data level voltage - well due to the nature of the i2c hardware you wont damage the MPR121 with the 5V of the arduino, but if you do notice issue reading from it, or not even finding it on the bus - try a logic level converter between the 2.

Over the years I made a few things with this great IC.On2 of the first things I created was a game for my kid, the letters on the top are connected to 2 MPR121 and each touch will trigger an mp3 record of me saying the letter name.

I also at the same time experimented with the bare conductive paint - it’s a lot of fun, and works great with the MPR121.


Code

  • Simple on/off led on pin 0/1
Simple on/off led on pin 0/1Arduino
It show the option of turn on and off a led that is connected on pin 3.
Using the pin 0 touch of the mpr121 for on and the 1 on release for off.
#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);
        }
      }
    }
  }
}

Schematics

Create Touch Buttons on Any Surface Using the MPR121 Capacitive Sensor

Manufacturing process

  1. Lightning Detection with Raspberry Pi and AS3935: A Practical Guide
  2. Seamless Arduino‑Raspberry Pi 2 I2C Integration for IoT Sensor Projects
  3. Revolutionize Manufacturing Training with OMEP’s ‘Ready or Not’ Simulation Game
  4. Arduino Light & Sound Display: US National Anthem
  5. Capacitive Touch‑Sensing 3‑D Printed Prosthetic Hand – Arduino‑Controlled Actuation
  6. Accurate AC Current Measurement with the ACS712 Sensor on Arduino
  7. Control Any Device with Your TV Remote Using Arduino IR – Step-by-Step Tutorial
  8. Mastering Glass Machining: A Complete Guide Using CNC Routers
  9. Expert Surface Grinding Techniques for Machining Steps
  10. Exploring the Benefits of CNC Mill‑Turn Machining