const int encoder = 3; // AMS AS5048 encoder int pos=0; //mechanical position of shaft void setup() { Serial.begin(9600); pinMode(encoder, INPUT); } void loop() { pos=pulseIn(encoder,HIGH);//read encoder pulse Serial.print(pos); Serial.print('\n'); delay(10); }