Help with rotary encoder on arduino uno

I'm trying to make a controller out of a arduino uno, I have made the arduino show up as a controller on windows, I also have code that should work, but I have no idea how to connect the encoder so the code will make it work.

Video I'm following : https://www.youtube.com/watch?v=CPWPPu2dR7M

Please, post the picture of your encoder.

OK, to be clear you want to use the arduino as a game controller.
We need the data on your encoder. Where did you get it, can you provide a link?

https://shorturl.at/m7EHo

encoderpng

I can't raed well. Please, write the Model No. of the encoder.

e38s6g5-600b-g24n

1 Like

1. This is the pin signatures (Fig-1, taken from net) for the wires of your encoder.
image
Figure-1:

2. You may search net for posts and tutorials. I have no experinece working with this type of encoder.

Also:

You need to show us how you have (or intend) to connect it, I'm not going to watch a video to find out.

This is what I actually need help with, I dont know how to connect it, or what to change on the code to make it work.

The tutorial I was watching is using a potentiometer that has 3 wires, the rotary encoder I am using has 4 wires, I have no idea how to change the code to make the rotary encoder work rather than the intended 3 wired potentiometer.

The code is using an analog pin for what should be a potentiometer, but I've read some places that analog pins don't work for rotary encoders.

"controllerData.leftStickX = analogRead(A0) >> 2;"

This part of the code is whats gotten me confused as I'm really new to microcontroller stuff.
I just don't know what to change the code to to make the rotary encoder work in place of the potentiometer.

(I know I should've probably said all this stuff on the starting post mb)

You can't just connect a rotary encoder like a pot. Its a completely diffferent thing.
As youre out of your depth with this I'd suggest you start by using a pot.

Then read this

Outputs of an encoder:
Encoder

If you follow the signals from left to right you’ll see that where A has a positive edge B is low.

Running in the other direction, where A has a positive edge B is high.

This way you’ll know to count up or down.

Note that the encoder from post #5 has no zero point.

1 Like

Try the encoder library and its examples. Its documentation is good too:

https://www.pjrc.com/teensy/td_libs_Encoder.html

1 Like