Thanks pylon!
What to do with the BLUE wire ?
BROWN - 5V
SMELD - GND
I have Arduino Diecimila. Arduino Diecimila's digital pins 2 and 3 can be used as External Interrupts. I don't understand Interrupt service and how to connect OUTA and OUTB if I want to know encoder turning direction (CW or CCW)..
Here is Example 1 from arduino playground:
/* Read Quadrature Encoder
* Connect Encoder to Pins encoder0PinA, encoder0PinB, and +5V.
*
* Sketch by max wolf / www.meso.net
* v. 0.1 - very basic functions - mw 20061220
*
*/
int val;
int encoder0PinA = 3;
int encoder0PinB = 4;
int encoder0Pos = 0;
int encoder0PinALast = LOW;
int n = LOW;
void setup() {
pinMode (encoder0PinA,INPUT);
pinMode (encoder0PinB,INPUT);
Serial.begin (9600);
}
void loop() {
n = digitalRead(encoder0PinA);
if ((encoder0PinALast == LOW) && (n == HIGH)) {
if (digitalRead(encoder0PinB) == LOW) {
encoder0Pos--;
} else {
encoder0Pos++;
}
Serial.print (encoder0Pos);
Serial.print ("/");
}
encoder0PinALast = n;
}
Please help me with Interrupt routine and which code is than usable (Interrupt Example, Interrupt Example (the Encoder interrupts the processor)) ??