the code is not working as expected before rotating the rotary encoder it prints anticlockwise and when turned it prints clockwise and increments +1 even the rotary encoder is rotated anticlockwise...
wouldn't you need to do that if you wanted to recognize each possible encoder step?
the interrupt would read the state of both inputs to determine 1 of 4 encoder states, and based on the previous state update the encoder position. this approach seems a little beyond the OPs current understanding.
a simpler starting point is to simply configure an interrupt on the RISING edge of one input and read the other input to determine the direction
my end goal is to Design a linear actuator that has a rotary encoder as a position sensor. It should be able to travel to a commanded position ( say 20 cm when commanded).
when i flashed the code to esp32s3 then after that what I did was just opening serial monitor and there was printed "Anti-clockwise 0" and if I rotate to clockwise the name anti clockwise changes to clockwise and 0 increments by -1... then after that what i did was pushed the button esp32s3 the "RST" button and now the serial monitor is showing "Anticlockwise 0" and this time I turned to anticlockwise. the name Anticlockwise changed to clockwise and increments by -1....
again, I copied your code and pasted and flashed into esp32s3 same thing happens...may there is a hardware problem.... the code which first posted at the beginning actually that work with my previous rotary encoder. when turned clockwise it will prompt clockwise and if otherwise it will prompt anticlockwise but sometimes when rotate two or three turns it shows wrong direction... but now Iam using another rotary encoder module
Try the SingleEncoder example from the link I provided in Post #7.
All you have to do is change the '2' and '3' in this line: NewEncoder encoder(2, 3, -20, 20, 0, FULL_PULSE);
To the pin numbers you're using for your ESP32.
If you get two counts per encoder detent, change FULL_PULSE to HALF_PULSE.
The way you are reading the encoder, there is NO reason to have signalB generating an interrupt. You'd get the same result by removing that interrupt. However, you are also using only 1/4 of the resolution of the encoder. If you want full resolution, you need to have BOTH interrupts, but separate interrupt handlers for each.