Advertisement
pleasedontcode

Bluetooth Counter rev_04

Dec 9th, 2023
104
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 Counter
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-12-10 05:01:53
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* compare the number of ble peripherals with rssi */
  21.     /* value above -40 with buetooth peripherals below */
  22.     /* -40. do not detect blutooth peripherals with rssi */
  23.     /* value above -60 */
  24. /****** SYSTEM REQUIREMENT 2 *****/
  25.     /* compare the number of ble peripherals with rssi */
  26.     /* value above -40 with buetooth peripherals below */
  27.     /* -40. if a is more send 9 volts to pin 13. if b is */
  28.     /* more 9 volts to pin 11 .send do not detect */
  29.     /* blutooth peripherals with rssi value above -60 */
  30. /****** END SYSTEM REQUIREMENTS *****/
  31.  
  32. /****** DEFINITION OF LIBRARIES *****/
  33. #include <Arduino.h>
  34. #include <SoftwareSerial.h>
  35.  
  36. /****** FUNCTION PROTOTYPES *****/
  37. void setup(void);
  38. void loop(void);
  39.  
  40. /***** DEFINITION OF Software Serial *****/
  41. const uint8_t d_HC05_mySerial_PIN_SERIAL_TX_A0 = A0; // Define the pin for TX
  42. const uint8_t d_HC05_mySerial_PIN_SERIAL_RX_A1 = A1; // Define the pin for RX
  43. SoftwareSerial d_HC05_mySerial(d_HC05_mySerial_PIN_SERIAL_RX_A1, d_HC05_mySerial_PIN_SERIAL_TX_A0);
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.  
  49.   d_HC05_mySerial.begin(9600);
  50.   pinMode(13, OUTPUT); // Set pin 13 as output
  51.   pinMode(11, OUTPUT); // Set pin 11 as output
  52. }
  53.  
  54. void loop(void)
  55. {
  56.   // put your main code here, to run repeatedly:
  57.  
  58.   int bleCount = 0; // Counter for BLE peripherals
  59.   int rssi = -50; // Sample RSSI value
  60.  
  61.   // Check if BLE peripherals have RSSI above -40
  62.   if (rssi > -40) {
  63.     bleCount++;
  64.   }
  65.  
  66.   // Check if Bluetooth peripherals have RSSI below -40
  67.   if (rssi < -40) {
  68.     bleCount--;
  69.   }
  70.  
  71.   // Compare the number of BLE peripherals with RSSI value above -40
  72.   if (bleCount > 0) {
  73.     digitalWrite(13, HIGH); // Send 9 volts to pin 13
  74.   } else if (bleCount < 0) {
  75.     digitalWrite(11, HIGH); // Send 9 volts to pin 11
  76.   }
  77.  
  78.   delay(1000); // Delay for 1 second
  79. }
  80.  
  81. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement