# Esp32PcntEncoder **Repository Path**: tinytaro/Esp32PcntEncoder ## Basic Information - **Project Name**: Esp32PcntEncoder - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-13 - **Last Updated**: 2025-05-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Esp32McpwmMotor EncoderWith ESP32 PCNT. Example Encoder With ESP32 PCNT. ``` #include #include Esp32PcntEncoder encoders[2]; // 创建一个数组用于存储两个编码器 void setup() { // 1.初始化串口 Serial.begin(115200); // 初始化串口通信,设置通信速率为115200 // 2.设置编码器 encoders[0].init(0, 32, 33); // 初始化第一个编码器,使用GPIO 32和33连接 encoders[1].init(1, 26, 25); // 初始化第二个编码器,使用GPIO 26和25连接 } void loop() { delay(10); // 等待10毫秒 // 读取并打印两个编码器的计数器数值 Serial.printf("tick1=%d,tick2=%d\n", encoders[0].getTicks(), encoders[1].getTicks()); } ```