Touch Sensor
Last updated
Last updated
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).
Connecting to the NyBoard with wire as shown in the following picture, connect to the NyBoard Grove interface, which includes D6, D7:
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:
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.
With NyBoard V1_*, you can choose Arduino Uno.
For example, to modify the code for Bittle as shown below:
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:
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.
Connect the robot and computer with the USB adapter(USB uploader) or Bluetooth module.
https://github.com/PetoiCamp/Petoi_MindPlusLib/blob/main/examples/NyBoard/DoubleTouch_NyBoard.mp
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.
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.
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.
The test code is in the OpenCatESP32 project source code (ModuleTests/testDoubleTouch)
https://github.com/PetoiCamp/Petoi_MindPlusLib/blob/main/examples/BiBoard/DoubleTouch_BiBoard.mp
Power on the robot and click the Run button in Mind+.