(SKU:SEN0292) Multi touch control panel多点触控板

来自DFRobot Product Wiki
跳转至: 导航搜索

目录

简介

这是一款基于电容感应的多点触摸控制面板,板设五个触摸点,采用Gravity接口方式。人体触摸不同的点,将输出不同的电压值,支持多点同时触摸。

特性

  • 五个触摸点
  • PH2.0-3接口
  • 模拟信号输出

技术规格

  • 输入电压:3.3V~5V
  • 工作电压:3V
  • 接口类型:Gravity 3P数字接口
  • 触摸芯片:BS806B
  • 产品尺寸:54*54(mm)

引脚说明及尺寸

引脚说明
标号 名称 功能描述
+ VCC 电源正极(3.3~5.0V)
- GND 电源负极
A Analog 模拟输出

使用教程

连接示意图

Arduino_Multi touch control panel

准备

硬件

  • 1 x UNO控制板
  • 1 x Multi touch control panel模块

软件

关于如何安装库文件,点击链接
API接口函数说明请查看DFRobot_MultiTouchPad库介绍

示例代码

单点触摸例程

  • 示例一:串口打印被触摸的按键的键值,如用户触摸按键“1”,就串口打印“button 1 touched”。
/*!
 *  file SinglePointDetection.ino
 * 
 *  There are five buttons on the multi-touch pad: 0, 1, 2, 3, 4.
 *
 *  This example presents: Single point printing, which button is pressed to print the corresponding content
 *  
 *  Create DFRobot_MultiTouchPad object, take the analog pin as a parameter and tramsmit into the function when starting initialization.
 *  When the initialization is finished, call read function,view the print content.
 * 
 *  Copyright   [DFRobot](http://www.dfrobot.com), 2018
 *  Copyright   GNU Lesser General Public License
 * 
 *  version V1.1
 *  date 2018-11-8
 */

#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multiTouchPad;

// the setup routine runs once when you press reset:
void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch pad init.");
  while( !multiTouchPad.init(A0)){ //multiTouchPad.init 0:fail 1:sucess
    Serial.println("Please connect multi touch pad or choose real analog Pin or reset the board.");
    delay(1000);  
  }
  Serial.println("Multi touch pad init OK.");
}

// the loop routine runs over and over again forever:
void loop() 
{
  int touchNum = multiTouchPad.read();
  switch (touchNum){
    case DFMT_BUTTON_0:
      Serial.println("button 0 touched"); 
      break;
    case DFMT_BUTTON_1:
      Serial.println("button 1 touched");  
      break;
    case DFMT_BUTTON_2:
      Serial.println("button 2 touched");  
      break;
    case DFMT_BUTTON_3:
      Serial.println("button 3 touched"); 
      break; 
    case DFMT_BUTTON_4:
      Serial.println("button 4 touched"); 
      break;
    default:
      Serial.println("other");  
      break;
  }
  delay(50);       
}
IDE串口提示信息
  • 示例二:事件单点触发,若用户触摸某个按键,则执行相应按键的功能,用户可根据需求修改函数button_n_touch(n=0,1,2,3,4)的内容。
/*!
 *  file SinglePointCallback.ino
 * 
 *  There are five buttons on the multi-touch pad: 0, 1, 2, 3, 4.
 *
 *  This example presents: Single point callback function, the user realizes his own function by pressing the button
 *  
 *  Create DFRobot_MultiTouchPad object, take the analog pin as a parameter and tramsmit into the function when starting initialization.
 *  Set the callback function of the corresponding button, function implemented in callback function.
 * 
 *  Copyright   [DFRobot](http://www.dfrobot.com), 2018
 *  Copyright   GNU Lesser General Public License
 * 
 *  version V1.1
 *  date 2018-11-8
 */

#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multiTouchPad;

void button_0_touch()
{
  Serial.println("button 0 touched");  
}

void button_1_touch()
{
  Serial.println("button 1 touched");  
}

void button_2_touch()
{
  Serial.println("button 2 touched");  
}

void button_3_touch()
{
  Serial.println("button 3 touched");  
}

void button_4_touch()
{
  Serial.println("button 4 touched");  
}

// the setup routine runs once when you press reset:
void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch pad init.");
  while( !multiTouchPad.init(A0)){ //multiTouchPad.init 0:fail 1:sucess
    Serial.println("Please connect multi touch pad or choose real analog Pin or reset the board.");
    delay(1000);  
  }
  Serial.println("Multi touch pad init OK.");
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_0, button_0_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_1, button_1_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_2, button_2_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_3, button_3_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_4, button_4_touch);
}

// the loop routine runs over and over again forever:
void loop() 
{
  multiTouchPad.read();
  delay(50);        
}
IDE串口提示信息
  • 示例三:设置长按键的时间及按钮键值,如设置按钮“1”为长按键,长按时间为3s,则模块上电后长按按钮“1”3s后开启,此时按其他键则触发相应功能,再长按“1”键3s,则关闭控制板,此时按其他键则无效。
/*!
 *  file SwitchMode.ino
 * 
 *  There are five buttons on the multi-touch pad: 0, 1, 2, 3, 4.
 *
 *  This example presents: Set the switch, the switch is on, the button touches the callback function, the switch is closed, not executed
 *  
 *  Create DFRobot_MultiTouchPad object, take the analog pin as a parameter and tramsmit into the function when starting initialization.
 *  Set the callback function of the corresponding button.
 *  Set switch time and switch number(Five buttons can be used as switches).
 *  
 *  Copyright   [DFRobot](http://www.dfrobot.com), 2018
 *  Copyright   GNU Lesser General Public License
 * 
 *  version V1.1
 *  date 2018-11-8
 */


#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multiTouchPad;

void button_0_touch()
{
  Serial.println("button 0 touched");  
}

void button_1_touch()
{
  Serial.println("button 1 touched");  
}

void button_2_touch()
{
  Serial.println("button 2 touched");  
}

void button_3_touch()
{
  Serial.println("button 3 touched");  
}

void button_4_touch()
{
  Serial.println("button 4 touched");  
}

// the setup routine runs once when you press reset:
void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch pad init.");
  while( !multiTouchPad.init(A0)){ //multiTouchPad.init 0:fail 1:sucess
    Serial.println("Please connect multi touch pad or choose real analog Pin or reset the board.");
    delay(1000);  
  }
  Serial.println("Multi touch pad init OK.");
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_0,button_0_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_1,button_1_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_2,button_2_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_3,button_3_touch);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_4,button_4_touch);

  multiTouchPad.setOpenedKeyTime(3);
  //default 0, only one button can be set
  //multiTouchPad.setOpenedKey(0);
  multiTouchPad.setOpenedKey(1);
  //multiTouchPad.setOpenedKey(2);
  //multiTouchPad.setOpenedKey(3);
  //multiTouchPad.setOpenedKey(4);
}

// the loop routine runs over and over again forever:
void loop() 
{
  multiTouchPad.read();
  delay(50);       
 
}
IDE串口提示信息

多点触摸例程

  • 示例一:双键触摸回调组合,如将按键“0”和“2”设置为组合键,并设置回调参数函数double_touch1,该函数名及内部功能用户可自行定义。
/*!
 *  file TwoPresses.ino
 * 
 *  There are five buttons on the multi-touch pad: 0, 1, 2, 3, 4.
 *
 *  This example presents: press two buttons at the same time to make the program run the function the user customized
 *  
 *  Create DFRobot_MultiTouchPad object, take the analog pin as a parameter and tramsmit into the function when starting initialization.
 *  When the initialization is finished, call setDoubleFun function,set the numbers of the two buttons (the numbers should be different)\
 *  and the related callback function. Please note that the parameters of the buttons must be within 0~4. 
 * 
 *  Copyright   [DFRobot](http://www.dfrobot.com), 2018
 *  Copyright   GNU Lesser General Public License
 * 
 *  version V1.1
 *  date 2018-11-8
 */

#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multiTouchPad;

void double_touch1()
{
  Serial.println("double_touch1");  
}

void double_touch2()
{
  Serial.println("double_touch2");  
}

void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch pad init.");
  while( !multiTouchPad.init(A0)){ //multiTouchPad.init 0:fail 1:sucess
    Serial.println("Please connect multi touch pad or choose real analog Pin or reset the pad.");
    delay(1000);  
  }
  Serial.println("Multi touch pad init OK.");

  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_0|DFMT_BUTTON_2,double_touch1);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_1|DFMT_BUTTON_2,double_touch2);
}

void loop() 
{
  multiTouchPad.read();
  delay(50);       
}
IDE串口提示信息
  • 示例二:三键触摸回调组合,如将按键“0”,“3”和“4”设置为组合键,并设置回调参数函数threeble_touch1,该函数名及内部功能用户可自行定义。
/*!
 *  file ThreePresses.ino
 * 
 *  There are five buttons on the multi-touch pad: 0, 1, 2, 3, 4.
 *
 *  This example presents: press three buttons at the same time to make the program run the function the user customized
 *  
 *  Create DFRobot_MultiTouchPad object, take the analog pin as a parameter and tramsmit into the function when starting initialization.
 *  When the initialization is finished, call setTrebleFun function,set the numbers of the three buttons (the numbers should be different)\
 *  and the related callback function. Please note that the parameters of the buttons must be within 0~4. 
 * 
 *  Copyright   [DFRobot](http://www.dfrobot.com), 2018
 *  Copyright   GNU Lesser General Public License
 * 
 *  version V1.1
 *  date 2018-11-8
 */

#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multiTouchPad;

void threeble_touch1()
{
  Serial.println("threeble_touch1");  
}

void threeble_touch2()
{
  Serial.println("threeble_touch2");  
}

void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch pad init.");
  while( !multiTouchPad.init(A0)){ //multiTouchPad.init 0:fail 1:sucess
    Serial.println("Please connect multi touch pad or choose real analog Pin or reset the pad.");
    delay(1000);  
  }
  Serial.println("Multi touch pad init OK.");

  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_0|DFMT_BUTTON_3|DFMT_BUTTON_4,threeble_touch1);
  multiTouchPad.setButtonCombinationCallback(DFMT_BUTTON_0|DFMT_BUTTON_1|DFMT_BUTTON_2,threeble_touch2);
}

void loop() 
{
  multiTouchPad.read();
  delay(50);       
}
IDE串口提示信息

单多点混合例程

  • 程序功能:长按按钮“0”3s开启控制板,此时触摸按键“1”触发事件button_1_touch;若触摸组合按键“0”“2”触发事件double_touch1;若触摸组合组合按键“0”“3”“4”触发事threeble_touch1,若再次长按按钮“0”3s则关闭控制板,以上触发事件的函数名及内部功能用户可自定义。
#include "DFRobot_MultiTouchPad.h"
DFRobot_MultiTouchPad multitouch;

void button_1_touch()
{
  Serial.println("button 1 touched");  
}

void double_touch1()
{
  Serial.println("double_touch1");  
}

void threeble_touch1()
{
  Serial.println("threeble_touch1");  
}

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Multi touch board init.");
  while( !multitouch.init(A0)){
    Serial.println("Please connect multi touch board or choose real analog Pin or reset the board.");
    delay(1000);  
  }
  Serial.println("Multi touch board init OK.");
  multitouch.setOpenedKeyTime(3);
  multitouch.setOpenedKey(0);
  multitouch.setButtonCombinationCallback(DFMT_BUTTON_1, button_1_touch);
  multitouch.setButtonCombinationCallback(DFMT_BUTTON_0|DFMT_BUTTON_2,double_touch1);
  multitouch.setButtonCombinationCallback(DFMT_BUTTON_0|DFMT_BUTTON_3|DFMT_BUTTON_4,threeble_touch1);
}
void loop() {
  multitouch.read();
  delay(50);       
}
IDE串口提示信息

疑难解答

更多

  • [ 原理图]


DFshopping car1.png [Link DFRobot商城购买链接]

个人工具
名字空间

变换
操作
导航
工具箱