I use Arduino UNO’s pins 2 and 3 to connect the encoder’s outputs (Black cable -> pin 2 and White cable -> pin 3)
cable brown -> pin 5V of Arduino
cable blue -> pin ground
With this configuration, I have gotten a binary output.
So I increased the tension utilizing an external power supply 9V. Thus I have gotten a value which increases when I turn the encoder. Yet, when I turn left or turn right the encoder, the value increases only and I don’t know why.
The code on Arduino is the basic one using Encoder.h.
Here the code :
Thank you for your help, I tried with the code that you showed me.
Yet, it doesn’t still work. Indeed, the value changed everytime (0 then 1 then 0 then 1 and so on, or -1 then 0 then -1 then 0 and so on) even if I didn’t turn the encoder.
I tried other codes but still the same problem : value which increases when I turn left or turn right. If not value changes everytime like I explained above.
The last hypothesis is that my encoder is defected …
I am opened to all solutions. Thank you for your help !
I think that it is not so clear.
So here the connections that I did :
Black = pin 2
White = pin 3
Brown = VCC linked to external power supply 9V
Blue = ground linked to external power supply 9V
Shield = Ground on Arduino (orange wire in the picture)
I checked and I tried but it doesn’t still work. It increases only.
and @RoboCS, I looked at the two tutorials and I tried the parts that I have not tried yet but I have always the same problem. Indeed the value increases only.
I utilized the code that @igor_X sent it below with the image to know if the direction of rotation works correctly.
The direction changes even if I turn left only or if I turn right only, the value always changes.
I don’t know why …
If you have still ideas, thank you to share with me.
Thank you to help me
Test your encoder alone. Took an oscilloscope, connect your encoder to VCC and GND and analyzed the output signal. If don’t, your encoder is the problem.
Try to channel the pin connection in your arduino. You can try 3 and 4 or something like that (different).