4 rotary encoders. Only half work.

So I have 4 rotary encoders attached to an arduino mega2560 They are connected to (2,4) (3,5) (6,7) (11,12) The first two are working fine. The second two are doing something but it's jittery and mostly does nothing. All are using the same code.

Am I missing something obvious. I thought it might be to do with the pins I am using.

Am I missing something obvious.

Yes, you forgot to read and follow the directions in the "How to use this forum" post.

Which encoders? What code?

ok so i have been away from my project for a little while.

here is more info.

the encoders are

http://uk.rs-online.com encoder

and i am using the #include <Encoder.h> library

i don’t think it is an issue with the library tho as i have 2 encoders working totally fine. yet the same code doesn’t function similarly for encoders 3 and 4

i also don’t think it is a mechanical issue with some of the encoders as i have tried swapping them round and the issue doesn’t change. if it was a mechanical issue then i would expect it to move with the swap.

therefore i believe it must be some kind of issue with the board or the pins i have chosen to use.

i can copy the code but due to the nature of the project i am working on there is quite a lot of it and a fairly large chunk doesn’t relate to the encoders. i also don’t think is this as the same code is working totally fine with half my encoders.

Mrbim:
ok so i have been away from my project for a little while.

here is more info.

the encoders are

and i am using the #include <Encoder.h> library

i don’t think it is an issue with the library tho as i have 2 encoders working totally fine. yet the same code doesn’t function similarly for encoders 3 and 4

i also don’t think it is a mechanical issue with some of the encoders as i have tried swapping them round and the issue doesn’t change. if it was a mechanical issue then i would expect it to move with the swap.

therefore i believe it must be some kind of issue with the board or the pins i have chosen to use.

i can copy the code but due to the nature of the project i am working on there is quite a lot of it and a fairly large chunk doesn’t relate to the encoders. i also don’t think is this as the same code is working totally fine with half my encoders.

Make a small program that duplicates your fault.
Add that code to your message.
place

[code]

markup before your code example and

 [/code]

markup after your code.
Describe what you expected the code to to.
Describe what the code actually did.

post a simple schematic of how you connected the encoders to your Arduino.
It would be better to link to the Encoder’s DataSheet instead of a link to the sales item.

Provide a link to the actual library you are using. <Encoder.h> is not one of the libraries included with the Arduino environment. I have no idea which one it is.

My diagnosis is that one of two things are happening, The <Encoder.h> requires specific pin usage to support the encoders, or that the encoders are returning a very bouncy signal.

Without an example of your code, and the results on your hardware, it is almost impossible to guess correctly.

Chuck.

A while back I've posted an example sketch for rading 6 rotary encoders with a a MEGA2560. Please give it a try: http://forum.arduino.cc/index.php?topic=292891.msg2050603#msg2050603

How on earth can we help you if you won't share your code with us?

Have you actually bothered to even read the "how to use this forum" posting?

All I can say is you've done something wrong. Good luck.