I am wonder how the color could be made by random of RGB variable values. Here is the demo to show the color while I am using accelerator value getting from a BLE device.

Then the p5 web app will interact with my BLE peripheral device with changing RGB value!

const serviceUuid = "59668694-8d7d-11eb-8dcd-0242ac13000";
const characteristicsUUID = {
  x: "59668694-8d7d-11eb-8dcd-0242ac13000",
  y: "59668694-8d7d-11eb-8dcd-0242ac13000",
  z: "59668694-8d7d-11eb-8dcd-0242ac13000"
};
var characteristicX;
var characteristicY;
var characteristicZ;

let myBLE;

let r = 0;
let g = 0;
let b = 0;

function setup() {
  // Create a p5ble class
  myBLE = new p5ble();

  createCanvas(600, 400);
  background(r,g,b);

  // Create a 'Connect and Start Notifications' button
  const connectButton = createButton('Connect and Start Notifications')
  connectButton.mousePressed(connectAndStartNotify);
  
  // Create a 'Disconnect' button
  const disconnectButton = createButton('Disconnect')
  disconnectButton.mousePressed(disconnectToBle);
}

function draw() {
  background(r,g,b);
}

function connectAndStartNotify() {
  // Connect to a device by passing the service UUID
  myBLE.connect(serviceUuid, gotCharacteristics);
}

function disconnectToBle() {
  // Disonnect to the device
  myBLE.disconnect();
  // Check if myBLE is connected
  let isConnected = myBLE.isConnected();
  if(!isConnected){
    background(0,0,0);//when disconnected, empty the canvas
  }
}

// A function that will be called once got characteristics
function gotCharacteristics(error, characteristics) {
  if (error) console.log('error: ', error);
  console.log(characteristics.length);

  for (let i = 0; i < characteristics.length; i++) {
    if (characteristics[i].uuid == characteristicsUUID.x) {
      characteristicX = characteristics[i];
      myBLE.startNotifications(characteristicX, handleX,'int8');
    } else if (characteristics[i].uuid == characteristicsUUID.y) {
      characteristicY = characteristics[i];
      myBLE.startNotifications(characteristicY, handleY,'int8');
    } else if (characteristics[i].uuid == characteristicsUUID.z) {
      characteristicZ = characteristics[i];
      myBLE.startNotifications(characteristicZ, handleZ,'int8' );
    }else {
    console.log("nothing");
  }
}
  // Start notifications on the first characteristic by passing the characteristic
  // And a callback function to handle notifications


  // You can also pass in the dataType
  // Options: 'unit8', 'uint16', 'uint32', 'int8', 'int16', 'int32', 'float32', 'float64', 'string'
  // myBLE.startNotifications(myCharacteristic, handleNotifications, 'string');
}

// A function that will be called once got characteristics
function handleX(data) {
  //console.log('r: ', data);
 r = map(Number(data),-100,100,0,255);

}

function handleY(data) {
  //console.log('g: ', data);
 g = map(Number(data),-100,100,0,255);

}

function handleZ(data) {
  //console.log('b: ', data);
  b = map(Number(data),100,-100,0,255);

}