Capacitive Touch Kit For Arduino(SKU:DFR0129)

From DFRobot Electronic Product Wiki and Tutorial: Arduino and Robot Wiki-DFRobot.com

Introduction

Now, it is time to add a more fancy interactive way to your project. This DFRobot touch kit comes with three types touch sensors. An ipod styple wheel touch, a keypad touch which supports backlit and a grid touch pad which can recoginze something unique.

This kit utilizes the not very "latest" capactive touch technology which make the sensing very sensitive.

The kit is designed to be compatible with Arduino.

Connection Diagram

Keypad CD DF0129 CD.jpg


Wheel pad CD DFR0129 CD2.jpg


Touch pad CD DFR0129 CD3.jpg


NOTE: The pin number is the same to the PCB board one.  

Sample Code

Please download the touch kit library first.

This code is for WheelPad.

/*
 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);
}


This code is for KeyPad.

/*
 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==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);
}

This code is for TouchPad.

// #
// # 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 A2 (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);
}


More



Nextredirectltr.pngGo Shopping Capacitive Touch Kit For Arduino (SKU:DFR0129)

Category: DFRobot > Sensors & Modules > Sensors > Interactive Sensors