Moin Moin,
ich habe mal folgende Lib probiert: RotaryEncoder.h
Code:
#include <RotaryEncoder.h>
// Setup a RoraryEncoder for pins A2 and A3:
RotaryEncoder encoder(A2, A3);
void setup()
{
Serial.begin(9600);
Serial.println("SimplePollRotator example for the RotaryEncoder library.");
// You may have to modify the next 2 lines if using other pins than A2 and A3
PCICR |= (1 << PCIE1); // This enables Pin Change Interrupt 1 that covers the Analog input pins or Port C.
PCMSK1 |= (1 << PCINT10) | (1 << PCINT11); // This enables the interrupt for pin 2 and 3 of Port C.
} // setup()
// The Interrupt Service Routine for Pin Change Interrupt 1
// This routine will only be called on any signal change on A2 and A3: exactly where we need to check.
ISR(PCINT1_vect) {
encoder.tick(); // just call tick() to check the state.
}
long position = -999;
void loop()
{
static int pos = 0;
int newPos = encoder.getPosition();
if (pos != newPos) {
if(newPos < position){
Serial.print("Vor");
}else{
Serial.print("Zurueck");
}
position = newPos;
Serial.println();
pos = newPos;
if (newPos == 66)
delay(6600);
} // if
} // loop ()
// The End
Damit kann ich schon mal zuverlässig Vor und Zurück erkennen. Der Uno ist also schnell genug hab es nur scheiße programmiert....
werde es weiter versuchen
Lesezeichen