#include <Encoder.h>
// Define the pins connected to the encoder
#define ENCODER_PIN_A 2
#define ENCODER_PIN_B 3
// Create an Encoder object
Encoder myEnc(ENCODER_PIN_A, ENCODER_PIN_B);
long oldPosition = -999;
void setup() {
// Start the serial communication
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
void loop() {
// Get the current position of the encoder
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
// Print the new position to the serial monitor
Serial.println(newPosition);
}
}
Hey Experts,
I have a 360ppr rotary encoder when i use the basic code I've given above and rotate the encoder 360 degrees it gives out the value of 1440, whereas it should show 360, please help!
Thank you