yeah, how do you make it a string instead of a list?
The WriteStrings Block will send a single string or a List of strings. If you don't want a List, send a single value - or change how the data is received/processed in the Sketch.
Arduino C does not have particularly good string splitting functions.
is this really the best way of going about things? cant i just send it as an integer and read it also as an integer in the arduino code? the only problem with that is that it reads wrong
cant we just try to fix that?
First things first, did you try my App code snippet? Error or OK?
its an error
Please download and post each of those event block(s)/procedures here ...
Back to basics:
- How many integer values do you need to send from the App to the Arduino?
- Should they be sent in the same stream or individually?
- Why doesn't your Sketch have any BLE settings - UUIDs for example?
- What Arduino Model are you using?
- If your Arduino does not have built-in BLE, what BLE module/shield have you attached?
Please answer these question just as I have listed
- i dont know, it worked just fine with other projects before
- arduino uno
- im using the AT-09
OK - progress. Less haste is the message!
I think you probably made the wrong Bluetooth choice, there doesn't seem to be anything in your Project that benefits from using BLE instead of BT Classic.
I don't understand your "Real Servo" code but it seems to differentiate between the possible sources of the integer value.
Instead of: Serial.readStringUntil('\n');
We can try: Serial.parseInt() (therefore Secondinput should be initialised as an int)
well its not really benefiting from BLE, i just have BLE laying around so i kind of just used what i have lol
so like before, its reading, its just not returning the right values, the value on the first slider should be between 1000-1100, and here im getting numbers like 0,4, and 7
OK, try Write Bytes instead of Write Int (Fields of Block same as Int)
Failing that, we can return to sending a single string like so:
its the same but with wilder numbers getting longer the longer i moved the slider
im going to try the single string now
aw man, more gibberish
this is the code block
here's the snippet of the code
String Secondinput = Serial.readStringUntil('\n');
Serial.print( "SecondInput(" );
Serial.print( Secondinput );
Serial.println( ")." );
int RealServo = Secondinput.toInt();
Serial.print("Real Servo = ");
also i want to ask why "\n" is strung in with thumbposition? whats "\n" for?
That should be write strings!
(and read until \n in the Sketch)
It signals "end of string" for Serial.readStringUntil('\n');
To use Serial.available(), you must include the Software Serial Library.
Simplified Sketch for testing (if the last test with your Sketch also failed)
Note, enter the pin numbers for the AT-09.
BLE_ReceiveString.ino (1.9 KB)
.... but it's nice looking gibberish
I wonder if the Slider.PositionChanged event is firing too quickly one after another.
That could be factored out as a test by moving the PositionChanged blocks to a test Button.Click event, working off the Slider.thumbPosition value.