ultrasonic.hpp 387 B

12345678910111213141516171819202122232425262728
  1. #ifndef ULTRASONIC_H
  2. #define ULTRASONIC_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #define US_RX_0_PIN 2
  6. #define US_RX_1_PIN 3
  7. #define US_TX_0_PIN 4
  8. enum usState_t {
  9. idle,
  10. rxPending,
  11. counting,
  12. finished
  13. };
  14. struct usData_t {
  15. uint16_t pulseStart;
  16. uint16_t duration;
  17. enum usState_t state;
  18. };
  19. void us_init();
  20. void us_transmit();
  21. long us_get_duration(byte sensor);
  22. #endif