Get Started with Capacitive Touch Kit

Get Started with Capacitive Touch Kit © GPL3+

In between a new project I decided to make a small tutorial on capacitive touch pad for your next project.

  • 6,528 views
  • 4 comments
  • 32 respects

Components and supplies

About this project

For my next project I'm going to use some capacitive touchpad, and before releasing it, I decided to make a small tutorial about the kit that I received for DFRobot.

The kit brings 3 touchpads:

  • Numeric keypad
  • Wheel pad
  • Touch pad

Connector board and rainbow cable. The kit only allow the use of one pad at a time connected to the Arduino. To start you will need the touch kit library, available here. Download and install it on your Arduino Library folder.

Schematic

Just follow one of the schematic, to connect them in your arduino board.

The communication is done trough I2C (A4 and A5 for arduino UNO) and an adicional pin D2 (I did not confirm this but I think that this library need an interruption pin, so I do not know about compatibility with other boards)

Code

Just do to the example folder of your Arduino IDE locate the MPR121 folder and load the example code according to the keypad that you have connected.

Or upload the ones in the attachment files.

Test it.

Conclusion

I've you like this project, do not forget to click it as Favorite.

I'm starting my Youtube channel, so fell free to stop by and subscribe it to be notified of the latest video.

Check also my previous tutorials.

Also, all suggestions and improvements are welcome.

"Do not get bored, do something"

Code

TouchWheel.pdeArduino
TouchWheel.pde
MPR121 WhellPad Example Code

by:Waiman Zhao
Mail:Binpower@foxmail.com
/*
 TouchWheel.pde
 MPR121 WhellPad Example Code
 
 by:Waiman Zhao
 Mail:Binpower@foxmail.com
 created on: 11/2/14
 license: CC-SA 3.0
 
 Hardware: 3.3V Arduino Pro Mini
           SDA -> A4
           SCL -> A5
           IRQ -> D2
*/


#include <Wire.h>
#include <mpr121.h>

int key = 0;


// =========  setup  =========
void setup()
{ 
	//  initialize function
  Serial.begin(19200);
  Wire.begin();
  CapaTouch.begin();

  delay(500);
  Serial.println("START"); 
}


// =========  loop  =========
void loop()
{
   key=CapaTouch.keyPad();
 
  if (key==1)             
  { Serial.print("wheel:");
  Serial.println("0");
  }
   if (key==4)
  { Serial.print("wheel:");
  Serial.println("1");
  }
   if (key==7)
  { Serial.print("wheel:");
  Serial.println("2");
  }
   if (key==11)
  { Serial.print("wheel:");
  Serial.println("3");
  }
   if (key==2)
  { Serial.print("wheel:");
  Serial.println("4");
  }
   if (key==5)
  { Serial.print("wheel:");
  Serial.println("5");
  }
  
   if (key==8)
  { Serial.print("wheel:");
  Serial.println("6");
  }
   if (key==0)
  { Serial.print("wheel:");
  Serial.println("7");
  }
   if (key==3)
  { Serial.print("wheel:");
  Serial.println("8");
  }
	delay(200);
}
Keypad.pdeArduino
Keypad.pde
MPR121 Keypad Example Code

by:Waiman Zhao
Mail:Binpower@foxmail.com
created on: 11/2/14
license: CC-SA 3.0
/*
 Keypad.pde
 MPR121 Keypad Example Code
 
 by:Waiman Zhao
 Mail:Binpower@foxmail.com
 created on: 11/2/14
 license: CC-SA 3.0
 
 Hardware: 3.3V Arduino Pro Mini
           SDA -> A4
           SCL -> A5
           IRQ -> D2
*/


#include <Wire.h>
#include <mpr121.h>

int key = 0;


// =========  setup  =========
void setup()
{ 
	//  initialize function
  Serial.begin(19200);
  Wire.begin();
  CapaTouch.begin();

  delay(500);
  Serial.println("START"); 
}


// =========  loop  =========
void loop()
{
  key=CapaTouch.keyPad();

  if (key==11)
  { Serial.print("key:");
  Serial.println("*");
  }
  else if(key==12)
  {
    Serial.print("key:");
  Serial.println("#");
  }
  else if(key>=0){
    Serial.print("key:"); 
    Serial.println(key); 
  }
	delay(200);
}
Capacitive touch pad Arduino
Editor : Jiang from DFRobot
Data : 19.11.2012
E-Mail : jianghao0716@gmail.com
// #
// # Editor    : Jiang from DFRobot
// # Data      : 19.11.2012
// # E-Mail    : jianghao0716@gmail.com

// # Product name  : Capacitive touch pad 
// # Version  : 0.4
// # Power supply: 3.3v
// # Connection:
// #       SDA (MPR121) -> PIN A4 (Arduino)
// #       SCL (MPR121) -> PIN A5 (Arduino)
// #       IRQ (MPR121) -> PIN D2 (Arduino) 

#include <Wire.h>
#include <mpr121.h>

int X ;           // X-coordinate
int Y ;           // Y-coordinate

// =========  setup  =========
void setup()
{ 
  //  initialize function
  Serial.begin(19200);
  Wire.begin();
  CapaTouch.begin();

  delay(500);
  Serial.println("START"); 
}


// =========  loop  =========
void loop()
{   
  X=CapaTouch.getX();              // Get X position.
  Y=CapaTouch.getY();              // Get Y position.
  if(X>=1&&X<=9&&Y>=1&&Y<=13)
   {                                 // Determine whether in the range.If not,do nothing.
      Serial.print("X=");
      Serial.print(X);
      Serial.print("  Y=");
      Serial.println(Y); 
   }
  delay(200);
}

Schematics

Keypad
Schematic 1 qrqxs49ufb
Wheel Pad
Schematic 2 ceerrywil9
Touchpad
Schematic 3 hifvlfbtdj

Comments

Similar projects you might like

Capacitive Touch Keyboard Extension with Leonardo

Project tutorial by Alex Wulff

  • 8,436 views
  • 2 comments
  • 20 respects

Touch Less Touch Switch - A touch alternative UI

Project tutorial by Jithesh Thulasidharan

  • 2,863 views
  • 2 comments
  • 7 respects

3D Printed Prosthetic Hand with Capacitive Touch Sensing

Project tutorial by Amal Mathew

  • 7,907 views
  • 7 comments
  • 34 respects

Multi-Octave Portable Capacitive Touch Piano

Project tutorial by Sridhar Rajagopal

  • 4,787 views
  • 0 comments
  • 11 respects

Portable Capacitive Touch Piano

Project tutorial by Sridhar Rajagopal

  • 9,692 views
  • 5 comments
  • 15 respects

Grove Starter Kit for Arduino: Touch sensor

by Grant

  • 1,860 views
  • 1 comment
  • 3 respects
Add projectSign up / Login