PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

30 lines
741B

  1. /* Encoder Library - Basic Example
  2. * http://www.pjrc.com/teensy/td_libs_Encoder.html
  3. *
  4. * This example code is in the public domain.
  5. */
  6. #include <Encoder.h>
  7. // Change these two numbers to the pins connected to your encoder.
  8. // Best Performance: both pins have interrupt capability
  9. // Good Performance: only the first pin has interrupt capability
  10. // Low Performance: neither pin has interrupt capability
  11. Encoder myEnc(5, 6);
  12. // avoid using pins with LEDs attached
  13. void setup() {
  14. Serial.begin(9600);
  15. Serial.println("Basic Encoder Test:");
  16. }
  17. long oldPosition = -999;
  18. void loop() {
  19. long newPosition = myEnc.read();
  20. if (newPosition != oldPosition) {
  21. oldPosition = newPosition;
  22. Serial.println(newPosition);
  23. }
  24. }