Petoi Doc Center
🇺🇸English
Search
K

Touch Sensor

Function introduction

The sensor contains two touch parts (left and right) and can detect changes in capacitance when a finger approaches. This means the touch sensor will output a high level whether your finger touches lightly or presses hard. You can realize the function you want by judging the detected value (1 for high level, 0 for low level).

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture, connect to the NyBoard Grove interface which include D6, D7:
For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth, or attached to the top of Nybble's head), of course, you can also use your creativity according to your needs.

Software setup

The code using this sensor has been integrated into the OpenCat project. Uncomment the line #define DOUBLE_TOUCH in the OpenCat.ino, as shown in the figure below, and then use the Arduino IDE to upload the sketch to the robot main board, which can reproduce the example function of integrating the robot action.

Arduino C++ demo

If you want to test the function of a touch sensor alone or want to learn more about its principle. You can use the Arduino IDE to upload the demo sketch(doubleTouch.ino), as shown below:
This demo sketch implements real-time printing of the detection values of D6 and D7 pins in the serial monitor:

The demo sketch

doubleTouch.zip
573B
Binary

Mind+ Demo

If you want to use the sensor with the Mind+ program:
  1. 1.
    You must upload the OpenCat.ino as follows, uncomment the line #define GROVE_SERIAL_PASS_THROUGH in the OpenCat.ino:
  2. 2.
    Follow the instruction to import the Petoi Coding Blocks in the app Mind+, and load the Mind+ code file.
  3. 3.
    Connect the robot and computer with the USB adapter(USB uploader) or Bluetooth module.
  4. 4.
    Power on the robot and click the Run button
    in Mind+.

Mind+ demo code

DoubleTouch.mp
280KB
Binary