How to send the value of 2 Sliders by Bluetooth to Arduino?

I'm trying to send the value of 2 sliders to Arduino by Bluetooth.

I have managed to send the values (from 0 to 100) of the two sliders separated by "|", the problem is that in the Arduino terminal, it appears cut character by character (for example, if the sliders are in positions 10 and 35 respectively, in the terminal I get "1" in one line, "0" in the next line, then "|", "3" and finally "5") all separated line by line.

This is the Arduino code:

#include <SoftwareSerial.h>
SoftwareSerial BT(10,11);
char value;

void setup() {
Serial.begin(9600);
BT.begin(9600);
}
void loop() {
if( BT.available() ){
value=BT.read();
Serial.println(value);
}

And the App Inventor one in the image and the aia:


Pruba_BT_1.aia (3.0 KB)

Hello Martisus

Generally speaking, nothing wrong with your App Inventor code that would produce the result you see.

Things that are wrong:

  1. Initialize both variables with an integer (math block), not the value from the component.

  2. Use a single Block ("Any Component") to capture the changed value of either slider.

In your Sketch, give 'value' a size so that it is handled as a C string e.g.
char value[]; This is where your issue is :slight_smile:

Here an example:

You can also use this extension and send the information in the Touch_Up event

No veo ninguna diferencia significativa entre tu programa y el mio...
supongo que el problema debe estar en el codigo de Arduino (como ademas ha dicho ChrisWard).
Podrias mandarme el tuyo?

It's on the topic.