PaulStoffregen / Encoder

Quadrature Encoder Library for Arduino
http://www.pjrc.com/teensy/td_libs_Encoder.html
540 stars 239 forks source link

[ Feature Request ] : Seeeduino XIAO : support hardware interrupts #77

Open ezhik1 opened 2 years ago

ezhik1 commented 2 years ago

Description

The Seeeduino XIAO doesn't play nice with this library. Works great on an arduino nano, with hardware interrupts, but fails to pick up any inputs when ported to the xiao.

Steps To Reproduce Problem

Hardware & Software

Board

Arduino IDE version : 1.8.16 Board: SEEEDuino XIAO Operating system & version: Windows 10 Any other software or hardware? : Nope

Arduino Sketch


/* Encoder Library - Basic Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these two numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder myEnc(5, 6);
//   avoid using pins with LEDs attached

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);
  }
}

Errors or Incorrect Output

No output from .read()