Arduino mega and uno
I have a OEM rotary encoder with 2 contacts on one side and three the other. The two contacts are a switch but the other three on the opposite side must be wired as... gnd, 5v, digitalx?
I cannot find a diagram.
Arduino mega and uno
I have a OEM rotary encoder with 2 contacts on one side and three the other. The two contacts are a switch but the other three on the opposite side must be wired as... gnd, 5v, digitalx?
I cannot find a diagram.
Welcome to the forum
Do you have a multimeter ?
No.
They are almost certainly should be wired as signal 1, ground, and signal 2.
Each signal should be wired with a pull up resistor to 5V.
With a meter you should see each signal make and break the connection to ground. Unless the encoder is one that clicks when you rotate it. Then the signals will change so rapidly that you will not measure any change with a resistance meter.
Plug 'encoder schematic' into your favorite seach engine.
Great thanks
Moderator edit
Link removed. Why did you post it ?
I'm feeling really stupid. I have tried virtually everthing here
> Citation
half the sketches put the middle pin to gnd and the others to 5v, but nothing seems to work. Either nothing shows in the serial monitor or it spews out an endless line of numbers without me turning it.
I've even tried checking the encoder pins with an example button sketch https://arduinogetstarted.com/tutorials/arduino-button
and a multimeter. I see the circuit is made and broken with each click in each direction on each pin.
I'm not an engineer or electrician but must be really dumb.
I've just retried this sketch testing only the data pins,
https://www.circuitbasics.com/how-to-setup-and-program-rotary-encoders-on-the-arduino/
the counter in the serial monitor increments without me touching anything!
The sketch works correctly in WOKWI - sketch.ino - Wokwi ESP32, STM32, Arduino Simulator.
You have done something wrong. Post a schematic of your circuit as built, the one in front of you, not a copy of the fritzing diagram. Hand drawn is OK, just clearly label everything. Include a copy of your sketch, in code tags.
Hi, @rooman62
Welcome to the forum.
Can you please post your code
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, component names and pin labels.
Can you please post images of your project so we can see your component layout?
In particular an image of your rotary encoder.
Tom..
Which means you have a floating input. That is one that is not connected to any voltage.
My best guess is that you missed a pull up resistor.
Get the full story about floating inputs here:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
@Grumpy_Mike
I'll reassemble the setup and furnish all (I hope) needed info this evening or tomorrow but I know the most difficult thing to debug is me! I am reading the inputs tuto (again).
Thanks in advance.
@dougp tks for the wokwi link, looks really great.
All, I think I must return to the initial question, I need the equivalent pinout for a 3/2 pin encoder.
The middle pin of the three must be 5v?
And the two switch pins should then be a digital pin and ground but which is which?
The middle pin is common to the other two. Assuming a KY-040 type, it's a mechanical switch and can be connected to ground or whatever voltage supply you're using - you just have to set up the other two inputs and the Arduino input configuration to account for that. Most use the S3 wiring as shown below with INPUT_PULLUP enabled.
It's a mechanical switch, it's not polarity sensitive. Connect however is convenient for you.
You guys have motivated me to find a solution, I have! I spent all my lunch break reading up and a big part of this evening.
This is the wokwi schematic
here
and a photo.
I am certain that I had dodgy connections so I started thid evening by soldering wires to the encoder rather than trying to force it in to the breadboard.
I'll modify this solution now to incorporate the encoder in my Flightgear simpit project.
Grazie mille to you all.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.