PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

30 linhas
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. }