Data from the slider for Bluetooth

Hi all! Tell me how to get split data from the slider movement in the serial port monitor? Thank you

#include <SoftwareSerial.h>

String R = " ";
int T;
int T2;

SoftwareSerial mySerialBT(10,9);

void setup() {
  Serial.begin(9600);
  mySerialBT.begin(9600);

}

void loop() {
    if (mySerialBT.available() == 1) {
      R = mySerialBT.readString();
      delay(200);
      Serial.println(R);
      if (R == "A") {
        pinMode(12, OUTPUT);
         digitalWrite(12, 1);
      } else if (R == "B") {
        pinMode(12, OUTPUT);
         digitalWrite(12, 0);
      }
    }

}

In blocks:
Add a | tag at the end of each string you send.

In code arduino:

void loop() {
    if (mySerialBT.available()) {
      R = mySerialBT.readStringUntil('|');
      delay(200);
      Serial.println(R);
      if (R == "A") {
        pinMode(12, OUTPUT);
         digitalWrite(12, 1);
      } else if (R == "B") {
        pinMode(12, OUTPUT);
         digitalWrite(12, 0);
      }
    }

}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.