Advertisement
pleasedontcode

"Bluetooth Detection" rev_02

Dec 8th, 2023
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Bluetooth Detection"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-08 06:46:17
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* scan for low energy bluetooth peripherals */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* scan for bluetooth periphrals and if 1 is detected */
  23.     /* then send 9 volts to pin 13 */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28. #include <SoftwareSerial.h>
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF Software Serial *****/
  35. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
  36. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
  37. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_TX_A2 = A2;
  38. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_RX_A3 = A3;
  39. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_TX_A4 = A4;
  40. const uint8_t BLE_HC05_mySerial_PIN_SERIAL_RX_A5 = A5;
  41. SoftwareSerial BLE_HC05_mySerial1(BLE_HC05_mySerial_PIN_SERIAL_RX_A1, BLE_HC05_mySerial_PIN_SERIAL_TX_A0);
  42. SoftwareSerial BLE_HC05_mySerial2(BLE_HC05_mySerial_PIN_SERIAL_RX_A3, BLE_HC05_mySerial_PIN_SERIAL_TX_A2);
  43. SoftwareSerial BLE_HC05_mySerial3(BLE_HC05_mySerial_PIN_SERIAL_RX_A5, BLE_HC05_mySerial_PIN_SERIAL_TX_A4);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.  
  49.   BLE_HC05_mySerial1.begin(9600);
  50.   BLE_HC05_mySerial2.begin(9600);
  51.   BLE_HC05_mySerial3.begin(9600);
  52.  
  53.   pinMode(13, OUTPUT); // Pin 13 as output for sending 9 volts
  54. }
  55.  
  56. void loop(void)
  57. {
  58.   // put your main code here, to run repeatedly:
  59.  
  60.   /****** SYSTEM REQUIREMENT 1 *****/
  61.   /* scan for low energy bluetooth peripherals */
  62.   // Add your code to scan for low energy bluetooth peripherals here
  63.  
  64.   /****** SYSTEM REQUIREMENT 2 *****/
  65.   /* scan for bluetooth peripherals and if 1 is detected */
  66.   /* then send 9 volts to pin 13 */
  67.   // Add your code to scan for bluetooth peripherals here
  68.   // If 1 is detected, set pin 13 to HIGH
  69.   // Otherwise, set pin 13 to LOW
  70.  
  71.   // Example code to set pin 13 to HIGH if 1 is detected
  72.   if (1 /* is detected */) {
  73.     digitalWrite(13, HIGH);
  74.   } else {
  75.     digitalWrite(13, LOW);
  76.   }
  77.  
  78.   delay(1000); // Delay for 1 second
  79.  
  80. }
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement