Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. //UltrasonicDemo.ino
  2. #include "Ultrasonic.h"
  3.  
  4. void setup(){
  5. Serial.begin(SerialBaudRate); //115200
  6. while (!Serial) {delay(10);} //wait for serial to wake up
  7. UltrasonicSetup();
  8. }
  9.  
  10. void loop(){
  11. UltrasonicLoop();
  12. }
  13.  
  14. *********************************************
  15. //Excerpts from Ultrasonic.cpp
  16.  
  17. void UltrasonicSetup() {
  18. Serial.begin(SerialBaudRate); //115200
  19. while (!Serial) {delay(10);} //wait for serial to wake up
  20. D_show_cursor(false); //disable cursor on display
  21. D_cls();
  22. D_position(0, 0);
  23. Serial.print(F("Ultrasonic library loaded"));
  24.  
  25. pinMode(TRIGGER_PIN, OUTPUT); //TRIG(speaker pin)
  26. pinMode(ECHO_PIN, INPUT); //ECHO(microphone pin)
  27. attachInterrupt (digitalPinToInterrupt (ECHO_PIN), USInterruptTimer, CHANGE); //interrupt routine setup
  28. //attachPCINT(digitalPinToPCINT(ECHO_PIN), InterruptTimer, CHANGE); //when using PinChangeInterrupt.h
  29. delay(1000);
  30. D_cls();
  31. }
  32.  
  33. *********************************************
  34.  
  35. void UltrasonicSetup() {
  36. Serial.begin(SerialBaudRate); //115200
  37. while (!Serial) {delay(10);} //wait for serial to wake up
  38. D_show_cursor(false); //disable cursor on display
  39. D_cls();
  40. D_position(0, 0);
  41. Serial.print(F("HUGUltrasonic library loaded"));
  42.  
  43. pinMode(TRIGGER_PIN, OUTPUT); //TRIG(speaker pin)
  44. pinMode(ECHO_PIN, INPUT); //ECHO(microphone pin)
  45. attachInterrupt (digitalPinToInterrupt (ECHO_PIN), USInterruptTimer, CHANGE); //interrupt routine setup
  46. //attachPCINT(digitalPinToPCINT(ECHO_PIN), InterruptTimer, CHANGE); //when using PinChangeInterrupt.h
  47. delay(1000);
  48. D_cls();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement