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).

NyBoard

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture, connect to the NyBoard Grove interface, which includes D6, D7:

Software setup

Petoi Desktop App

  • You can use the Firmware Uploader within the Petoi Desktop App. Please select the correct Product type, Borard version, and Serial port. The mode should be Touch, so press the Upgrade the Firmware button. for example, Nybble, NyBoard_V1_2, COM5 as follows:

Arduino IDE

  • You can use Arduino IDE to upload and modify the source code.

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, use the Arduino IDE to upload the sketch to the robot main board, which can reproduce the example function of integrating the robot action.

Prepare the Arduino UNO development environment.

With NyBoard V1_*, you can choose Arduino Uno.

For example, to modify the code for Bittle as shown below:

Arduino module test code

If you want to test a touch sensor's function alone or learn more about its principles. You can use the Arduino IDE to upload the test code(testDoubleTouch.ino):

The test code is in the OpenCat project source code (ModuleTests/testDoubleTouch)

This demo sketch implements real-time printing of the detection values of D6 and D7 pins in the serial monitor:

Mind+ Demo

  1. You can upload the firmware via the Petoi Desktop App:

Or you can upload the OpenCat.ino as follows, uncomment the line #define GROVE_SERIAL_PASS_THROUGH in the OpenCat.ino:

For BiBoard, you can skip this step.

2. Follow the instructions to import the Petoi Coding Blocks in the app Mind+, and load the Mind+ code file.

  1. Connect the robot and computer with the USB adapter(USB uploader) or Bluetooth module.

Mind+ Demo code

https://github.com/PetoiCamp/Petoi_MindPlusLib/blob/main/examples/NyBoard/DoubleTouch_NyBoard.mp

BiBoard

Hardware setup

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

Petoi Desktop App

  • You can use the Firmware Uploader within the Petoi Desktop App.

    Please select the correct Product type, Borard version, and Serial port. The mode should be Standard, so press the Upgrade the Firmware button. for example, Bittle, BiBoard_V0_2, COM5 as follows:

    After uploading, open the serial monitor and use the serial command "XT" to switch to using the touch sensor mode.

Arduino IDE

  • You can use Arduino IDE to upload the sketch(OpenCatEsp32.ino).

    Use the latest OpenCatESP32 code to finish the setup. For example, to modify the code for Bittle as shown below:

    After uploading, open the serial monitor and use the serial command "XT" to switch to using the touch sensor mode.

Arduino module test code

The test code is in the OpenCatESP32 project source code (ModuleTests/testDoubleTouch)

Mind+ Demo code

https://github.com/PetoiCamp/Petoi_MindPlusLib/blob/main/examples/BiBoard/DoubleTouch_BiBoard.mp

Last updated