EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #116 background imageLoading...
Page #116 background image
SunFounder ESP32 Starter Kit
Code
Note:
You can open the file 6.1_fruit_piano.ino under the path of esp32-starter-kit-main\c\codes\6.
1_fruit_piano directly.
Or copy this code into Arduino IDE.
You can connect fruits to these ESP32 pins: 4, 15, 13, 12, 14, 27, 33, 32.
When the script runs, touching these fruits will play the notes C, D, E, F, G, A, B and C5.
How it works?
touchRead(uint8_t pin);
This function gets the touch sensor data. Each touch sensor has a counter to count the number of
charge/discharge cycles. When the pad is touched, the value in the counter will change because of
the larger equivalent capacitance. The change of the data determines if the pad has been touched or
not.
pin GPIO pin to read TOUCH value
This function returns a value between 0 and 4095, with a lower value indicating a stronger touch input.
Note: threshold needs to be adjusted based on the conductivity of different fruits.
110 Chapter 1. For Arduino User

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish