insight to Uno pins with limitations - pins 7. 8, 9

I wonder if somebody can give me some insight to any Uno pins with any limitations - pins 7, 8, 9, 10 in particular.

I was trying to run a cheap KY-040 rotary encoder that runs fine on pins 2, 3, 4 but not as its should on pins 7, 8, 9 or 8, 9, 10. They were all set as digitalRead.

Am I missing something???

I ended up moving LCD pins around to force the encoder to have 2, 3, 4 but it just didnt make sense. I couldn't find a solution from google-ing.

TIA

Pin 10 is the slave select for SPI. If you are interfacing with SPI devices you are generally limited to using pin 10 only as an output pin, not an input.

Pins 7-9 have other functions that might conflict, depending on what else you're doing.

Take a look at this: http://umsats.ca/wp-content/uploads/2013/02/Arduino_uno_Pinout.pdf

Only pins 2 and 3 can generate genuine HW interrupts. That is why 99% of the code for rotary switches that you will find in the forum uses pin 2 and 3. This is how the Arduino bootcode sets up the ATmega chip.

There are ways to set other pins to generate interrupts, however, this will make your code more complicated. You will have to read the ATmega datasheet and change some register values.

I would do this only if there is no way to use pins 2 and 3.

You could also write a polling routine for your rotary encoder, however, you would miss some turns of the knob if your routine is not extremely short. That is what interrupts are good for.

arduinoaleman

Try the rotary encoder code that jurs wrote for me here to select a value to show on a display.
Worked well for me.
http://forum.arduino.cc/index.php?topic=318170.15
Make sure your rotary encoder has proper IO filter on it, see page 2 of the datasheet:

This is about KY-040

I had my own personal experience with this device - so I posted some stuff on the Arduino forum ....

http://forum.arduino.cc/index.php?topic=242356

I posted this a while ago

Only pins 2 and 3 can generate genuine HW interrupts. That is why 99% of the code for rotary switches that you will find in the forum uses pin 2 and 3. This is how the Arduino bootcode sets up the ATmega chip.

The External interrupts being on pins 2+3 is nothing to do with the bootloader! It's just how the AVR H/W is!

As for the rest of the problem you can't tell with out seeing the code, SO OP post your code.

Mark

So, with no link to KY-040, I just saw cheap rotary encoder.

Yes, it is correct. INT0 and INT1 are hardwired to D2 and D3 on the Arduino Uno board and there is nothing you can do about it.

The bootcode cannot change this. It will simply take care that the proper settings in the EICRA and EIMSK registers are made.

However, the ATmega 328 supports 3 more interrupts (PCINT0, PCINT1, PCINT2). These pin change interrupts are supported on many digital pins and you can use the PCICR and PCMSK1 and PCMSK2 registers to control this.