How to modify some variable from app

Hi, I have a servo with PID control incorporated. Basing on the values of the parameters P, I, and D the speed and the behavior of the servo's motion can change. I would like to fit the app to have the possibility to change (not only with + and -, but directly write) the values of PID from the app to Arduino. Can you direct me to a link that I can use, please?

Welcome.

Community Arduino articles perhaps something useful here perhaps.

Servo articles control using App Inventor.

Other advice showing how to program with App Inventor. These are some resources to help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles

How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also look here http://kio4.com/appinventor/index.htm and here http://www.imagnity.com/tutorial-index/ for more tutorials.

Learn about components http://ai2.appinventor.mit.edu/reference/components/
and visit the Library http://appinventor.mit.edu/explore/library Help>Library on the MENU

Thank you so much @SteveJG Your tips are so useful and I am just using and testing them. Honestly, I will use the entire course!
At this moment I would like to have concrete help if it is possible. I used the 4° example in Bluetooth HC-06. Arduino. Send. Receive. Send text file. Multitouch. Image
I am sending Data from APP.
If data is 1 then the servo will move continuously based on the threshold of the imu.
If data is 2 then the servo will be turned off.
If data is 3 then I would like to let Arduino understand that it has to expect, after "3", a string with the format #,#,#*.
The problem is that this feature doesn't work and fix with the others. Those 3 numbers(#,#,#) are respectively P,I,D.
Can you help me with the structure of the code, please?

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(7,8);
#include <Arduino_LSM6DS3.h>
#include <DynamixelShield.h>

const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;

DynamixelShield dxl;
//This namespace is required to use Control table item names
using namespace ControlTableItem;
#define DEBUG_SERIAL Serial

char caracter;
String palabra;

String P;
String I;
String D;
int ind1;
int ind2;
int ind3;
int PID_state=0;
int walk_state=0;
int read_acc=0;
float Object_position_X = 170;
float Object_position_Y = 60;

float Athr = 0.22;
float Bthr = -0.1;

void setup(){
DEBUG_SERIAL.begin(57600);
delay(2000);
BTSerial.begin(57600);
delay(2000);
IMU.begin();
delay(2000);

dxl.begin(57600);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);

// Turn off torque when configuring items in EEPROM area
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);
// dxl.writeControlTableItem(CURRENT_LIMIT, DXL_ID, 15);
// dxl.writeControlTableItem(POSITION_P_GAIN, DXL_ID, 200);
// dxl.writeControlTableItem(POSITION_I_GAIN, DXL_ID, 4);
// dxl.writeControlTableItem(POSITION_D_GAIN, DXL_ID, 25);
dxl.torqueOn(DXL_ID);
DEBUG_SERIAL.print("Connect the device via bluetooth") ;
}

String Data;

void loop(){
if (BTSerial.available()>0){
Data=BTSerial.readString();
}

///WALK///

if(walk_state==0 && Data == "1"){
DEBUG_SERIAL.println(Data);
DEBUG_SERIAL.println("FUNZIONE WALKING ABILITATA");
PID_state=0;
walk_state=1;
read_acc=1;

          }
                if(read_acc==1){
                     float x,y,z;
            
                IMU.readAcceleration(x, y, z);
                DEBUG_SERIAL.print(y);
                DEBUG_SERIAL.print("\t");
                          if (y>Athr){
                          dxl.setGoalPosition(DXL_ID, 170,UNIT_DEGREE);
                            DEBUG_SERIAL.println("stance");
                          }
                          else if(y<Bthr){
                            dxl.setGoalPosition(DXL_ID, 60,UNIT_DEGREE);
                            DEBUG_SERIAL.println("swing");
                          }
                          else {
                          DEBUG_SERIAL.println();
                          }
                          }

if(walk_state==1 && Data == "2"){
DEBUG_SERIAL.println(Data);
DEBUG_SERIAL.println("FUNZIONE WALKING DISABILITATA");
walk_state=0;
read_acc=0;
delay(1000);
dxl.setGoalPosition(DXL_ID, 90,UNIT_DEGREE);

}

if(PID_state==0 && Data == "3" ){
DEBUG_SERIAL.println(Data);
DEBUG_SERIAL.println("define PID");
PID_state=1;
pidvalues();
}

}
void pidvalues() {
caracter = BTSerial.read();
palabra = palabra + caracter;
DEBUG_SERIAL.println(caracter);
DEBUG_SERIAL.println(palabra);
if(caracter == '*') {
palabra = palabra.substring(0, palabra.length() - 1); // Delete last char *
Serial.println(palabra);
ind1 = palabra.indexOf(',');
P = palabra.substring(0, ind1);
ind2 = palabra.indexOf(',', ind1+1 );
I = palabra.substring(ind1+1, ind2);
ind3 = palabra.indexOf(',', ind2+1 );
D = palabra.substring(ind2+1);

              Serial.print("P = ");
              Serial.println(P);
              Serial.print("I = ");
              Serial.println(I);
              Serial.print("D = ");
              Serial.println(D);
              Serial.println();
              palabra = "";
              delay(10);
         }

}

@DjangoTango

You can do tests directly by entering the numbers from the Serial.Monitor, without using Bluetooth, check example 18.

You can use readStringUntil, check example 27

In this example, I enter the values, 1 or 2 or 3,765,887,454 from the Serial Monitor for testing:

int mover = 0;
String x;

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

void loop() {
if(Serial.available()) {
// a = Serial.readStringUntil(',');
x = Serial.readStringUntil('\n');
x.trim();
Serial.println(x);
if (x.equals("1")){
Serial.println("Servo move");
mover = mover + 5;
Serial.println(mover);
delay(10);
}
if (x.equals("2")){
Serial.println("Servo off");
mover = 0;
Serial.println(mover);
delay(10);
}
if (x.startsWith("3")){
Serial.println("P,I,D");
Serial.println("Split this value.");
}
}
}