Closed DaisukeUra closed 7 years ago
I've try this code and it properly works.
#include <Encoder.h>
Encoder *myEnc;
void setup() {
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
myEnc = new Encoder(7, 8);
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc->read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}
I don't know why it works well. I think it remains some problem in library's code.
Thanks.
https://www.arduino.cc/en/Main/ArduinoBoard101
"change is only supported by pins 2, 5, 7, 8, 10, 11, 12, 13"
@PaulStoffregen Thanks. I know change supported pins.
Why does not the sample code below work?
#include <Encoder.h>
Encoder myEnc(7, 8);
void setup() {
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
}
}
This code is Encoder/examples/Basic/Basic.pde.
Hi there.
I use this library on my Arduino/Genuino 101. When only use "change" supported interrupt pins, such as 7&8, Encoder instance looks like doesn't count pulses. It is properly counting when I use "change" not supported pins. How I use "change" supported interrupt pins on this library?
Best regards.