Petoi Doc Center

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:
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.
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 code