PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
816B

  1. #include <PulsePosition.h>
  2. // Simple loopback test: create 1 output to transmit
  3. // test pulses, and 1 input to receive the pulses
  4. PulsePositionOutput myOut;
  5. PulsePositionInput myIn;
  6. void setup() {
  7. myOut.begin(9); // connect pins 9 and 10 together...
  8. myIn.begin(10);
  9. myOut.write(1, 600.03);
  10. myOut.write(2, 1500);
  11. myOut.write(3, 759.24);
  12. // slots 4 and 5 will default to 1500 us
  13. myOut.write(6, 1234.56);
  14. }
  15. int count=0;
  16. void loop() {
  17. int i, num;
  18. // Every time new data arrives, simply print it
  19. // to the Arduino Serial Monitor.
  20. num = myIn.available();
  21. if (num > 0) {
  22. count = count + 1;
  23. Serial.print(count);
  24. Serial.print(" : ");
  25. for (i=1; i <= num; i++) {
  26. float val = myIn.read(i);
  27. Serial.print(val);
  28. Serial.print(" ");
  29. }
  30. Serial.println();
  31. }
  32. }