Hugo Gomes
Published © GPL3+

Get Started with Capacitive Touch Kit

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

BeginnerProtip1 hour8,471
Get Started with Capacitive Touch Kit

Things used in this project

Story

Read more

Schematics

Keypad

Wheel Pad

Touchpad

Code

TouchWheel.pde

Arduino
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.pde

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

Credits

Hugo Gomes

Hugo Gomes

10 projects • 114 followers
http://www.hugogomes.net Youtube Channel - https://goo.gl/fnQLJo

Comments