ArduinoBLE - bleCharacteristic.value()

Query the current value of the specified BLECharacteristic.

Syntax

bleCharacteristic.value()

Parameters

None

Returns

  • The current value of the characteristic, value type depends on the constructor used

Example


// Bluetooth® Low Energy LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);



      if (switchCharacteristic.value()) {   // any value other than 0
          Serial.println("LED on");
          digitalWrite(ledPin, HIGH);         // will turn the LED on
        } else {                              // a 0 value
          Serial.println(F("LED off"));
          digitalWrite(ledPin, LOW);          // will turn the LED off
        }