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.

hc05_test.ino 891B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * hc05_test - Test the disconnect command
  3. *
  4. * When the main loop detects that a bluetooth device is connected it
  5. * disconnects the device.
  6. *
  7. * Montor the progress using the debug port.
  8. */
  9. #include <Arduino.h>
  10. #include "HC05.h"
  11. #ifdef HC05_SOFTWARE_SERIAL
  12. #include <SoftwareSerial.h>
  13. HC05 btSerial = HC05(A2, A5, A3, A4); // cmd, state, rx, tx
  14. #else
  15. HC05 btSerial = HC05(3, 2); // cmd, state
  16. #endif
  17. #ifdef DEBUG_HC05
  18. #ifdef DEBUG_SW_PORT
  19. extern SoftwareSerial DEBUG_PORT;
  20. #endif
  21. #endif
  22. void setup()
  23. {
  24. DEBUG_BEGIN(57600);
  25. DEBUG_PRINTLN("Setup");
  26. delay(3000); // this delay is for debugging convenience only
  27. DEBUG_PRINTLN("DelayComplete");
  28. btSerial.println(btSerial.findBaud());
  29. }
  30. void loop()
  31. {
  32. if (btSerial.connected()){
  33. DEBUG_PRINTLN("Connected");
  34. btSerial.cmd("AT+DISC", 1000);
  35. }
  36. else
  37. {
  38. DEBUG_PRINTLN("Disconnected");
  39. }
  40. delay(1000);
  41. }