Skip to content

bubao/esp32-ec11-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EC11 编码器项目

本项目基于 ESP32 开发板,使用 FreeRTOS 实现对 EC11 旋转编码器的读取和处理。

功能简介

  • 通过 GPIO 中断捕获 EC11 编码器的旋转信号。
  • 使用 FreeRTOS 信号量和任务处理旋转方向及位置。
  • 支持顺时针和逆时针旋转检测,并实时打印旋转位置。

硬件连接

编码器引脚 ESP32 GPIO 引脚
A GPIO4
B GPIO5

注意:请确保为编码器引脚启用上拉电阻。

软件依赖

  • ESP-IDF 开发框架
  • FreeRTOS(ESP-IDF 内置)

编译与烧录

  1. 安装 ESP-IDF
  2. 配置项目:
    idf.py set-target esp32-s3
    idf.py menuconfig
  3. 编译项目:
    idf.py build
  4. 烧录固件:
    idf.py flash
  5. 监控串口输出:
    idf.py monitor

使用说明

  1. 连接 EC11 编码器到 ESP32 的 GPIO4 和 GPIO5。
  2. 编译并烧录程序到 ESP32。
  3. 通过串口监控器查看编码器的旋转方向和位置变化。

日志示例

顺时针旋转:

I (1234) EC11_ENCODER: Rotated Clockwise, Position: 1

逆时针旋转:

I (5678) EC11_ENCODER: Rotated Counterclockwise, Position: 0

注意事项

确保 GPIO 引脚配置正确。

如果信号不稳定,可以尝试调整硬件电路或增加软件去抖动逻辑。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published