daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Sep 19th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <BLEAdvertisedDevice.h>
  2. #include <BLEDevice.h>
  3. #include <BLEScan.h>
  4.  
  5. const int PIN = 2;
  6. const int CUTOFF = -60;
  7.  
  8. void setup() {
  9.   pinMode(PIN, OUTPUT);
  10.   BLEDevice::init("");
  11. }
  12.  
  13. void loop() {
  14.   BLEScan *scan = BLEDevice::getScan();
  15.   scan->setActiveScan(true);
  16.   BLEScanResults results = scan->start(1);
  17.   int best = CUTOFF;
  18.   for (int i = 0; i < results.getCount(); i++) {
  19.     BLEAdvertisedDevice device = results.getDevice(i);
  20.     int rssi = device.getRSSI();
  21.     if (rssi > best) {
  22.       best = rssi;
  23.     }
  24.   }
  25.   digitalWrite(PIN, best > CUTOFF ? HIGH : LOW);
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top