I am trying to use a single Sparkfun RGB encoder connected to a ESP32 in order to create a menu style interface with a 16x2 LCD (serial) display. Under the Sparkfun product page for the RGB encoder and document link is a sample program but it is old, using the PinChngInt lib and trying it is buggy – keeps calling for new.h and I am stuck and I feel that since the ESP32 has all pins essentially interrupt-able – this code is geared more for the Arduino ATmega anyway.
Be nice to have a smooth running, debouncing code for encoder and push switch that I can adapt to the esp32. Any ideas?
Here’s the error message:
Arduino: 1.8.12 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”
In file included from C:\Users\cdrei\Documents\Arduino\RGB-RotaryEncoder-Sparkfun-Oct-2020-Test\RGB-RotaryEncoder-Sparkfun-Oct-2020-Test.ino:93:0:
C:\Users\cdrei\Documents\Arduino\libraries\PinChangeInt/PinChangeInt.h:129:17: fatal error: new.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board ESP32 Dev Module.
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
Thanks for your suggestion. I did try that library. When I test it, I see increments of 2 up or down. Sometimes it jumps 1 or 3 either way. I need it to increment and decrement steadily by one for menu purposes. I am looking for a couple 0.1uF caps to see if the hardware debounce helps. Could this have anything to do with these encoders being grey code?
Opening out the serial monitor I can see with a single click turn, I see it most often decrement one unit of count for a blip and then lock in at a two count. Most often anyway. So it must be a noisy encoder – using sparkfun breakout module too. No resistors or caps though SF recommends caps.
After trying all kinds of encoder libraries and github offerings, this site is the most informational and comprehensive coverage on encoders. The code works very well for my application too. Accolades and Kudos to this site:
https://www.best-microcontroller-projec … coder.html
I am critical of SF. This product and its breakout, #15141 & #11722 are still available and need a desperate update on the information and example code. Horrendous indeed. Not much help either and SF pushes us to the forum now when you used to be able to talk directly to people.
I have a library at https://github.com/SV-Zanshin/RotaryEncoder which controls a 3-color RGB LED rotary encoder, but you can remove the LED-related code. I believe it is robust.