I was reading about using rotary encoders when the word 'interrupt' was used several times. Checked it on the Arduino website. There are tutorials and references in the language but none of them explains what it is (thanks for nothing!). Checked it on wikipedia and it says something like 'notifying the hardware that there are changes'. So what the hell is that? Why, where, when and how should I use it? Would it hurt to write an explanation on the Arduino website???
Also, why do I need interrupt with the encoder? And why don't I need it for instance with a potentiometer? And which pin of the encoder goes to the interrupt input? And since the duemilanove has only two interrupt inputs, does that mean I can only use two rotary encoders?
An interrupt is a signal to the processor that something significant and time-critical has happened.
The processor should respond to the interrupt as soon as possibly (usually, but not always as soon as the current machine instruction has finished).
The signal could be external (from, say a UART or time), internal (from a fault condition, like the processor trying to access unmapped memory) or software (a supervisor call instruction).
A pot doesn't generate an interrupt, but the ADC to which it is connected could, to signal, for instance, that the ADC conversion is complete.
A shaft encoder may generate interrupts if the shaft it is connected to is turning fast enough, but if it is turning slowly, it may be more convenient to use polling.
Plenty of examples and explanations out there.
Also, why do I need interrupt with the encoder?
You don't have to use interrupts. It depends on how fast the encoder pulses are and if it's important or not if you 'miss' steps from the encoder or not. If your sketch is doing lots of other things as well as reading the encoder then you cannot prevent missing steps. Using interrupts to process the encoder steps means you can handle faster pulses, but even using interrupts is not sure thing that you won't miss encoder steps, say if coupled to a high RPM motor, there is always some limit in the real world
And why don't I need it for instance with a potentiometer?
A pot and a encoder are two very different components used in different applications, so I'm not sure I understand this question. A pot is normally not capable of continous rotation like a encoder.
And which pin of the encoder goes to the interrupt input?
Either of the channel A or B can be used to wire to the interrupt input pin. It's also possible to wire both A & B to interrupts 0 & 1 to have double the step resolution at the expensive of only being able to have one encoder
And since the duemilanove has only two interrupt inputs, does that mean I can only use two rotary encoders?
The simple answer is yes. If you don't use interrupts at all then you can wire as many encoders as you have free digital input pins avalble to you, however again without using interrupts there will be the possiblity of missing steps and the more encoders you try to read the more likely that is to happen. There is a way to utilize more interrupts on most all the I/O pins, but the Arduino core software does not provide any functions for that and you would have to write your own and it is not something for the inexperanced as you have to process all 8 pins in a port to determine which generated the interrupt signal.
Lefty
Thanks for the answers!