Arduino Button check in a MIT APP

Hi,

I didn't give up on this thing. I made a version, found a good sub-base for the app. For some reason it randomly throws this message, but when I touch the tablet, it disappears and then appears again.

Arduino Code:

int value_pot0;
int value_pot1;
String value;

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

void loop() {
value_pot0 = analogRead(A0);
value_pot1 = analogRead(A1);
value = (String) value_pot0 + "," + (String) value_pot1;
Serial.println(value);
delay(200); // It should be slower than the Clock Interval.
}


Cannot see a csv Block in your code?

Sorry i don't understand, so the App do not see the csv Block, or what?

Not sure you can stream the data (ReadLn) directly into a 'list from csv row' block. It looks like the data may include something, like a newline or carriage return character, that means it is not going to convert into a list as it is not a perfect csv row.

Try streaming to a Label to see what you actually receive.

I looked in the serial monitor, and i think this is good. So i dont know what is the Problem.

Could be occasional data corruption between the board and the Android Device - or perhaps it is arriving too fast.......

Actually, stream it into a TextBox so it can be copy-pasted if required.

Looking at your monitor results, there is a newline after every value pair? If the data is streamed too quickly, the App is receiving:

506,520 newline 506,520

......which is not a legitimate CSV row

stream 506, 520, 506, 520 (etc) with a newline at the end is what you want to make the Block work, but if you need those pairs to be separated, send them as text like this:

506,520|506,520, etc ending with a newline. Stream goes into a var and the you can use the text split block @ '|' to separate the pairs into a List.

Huh, that was to many information me. My brain have to understand this.

Maybe you have not had enough coffee :joy:

What is your App Clock Timer set to? It could be that all you need to do is increase the App Clock Timer interval and increase the Arduino Loop time interval.

Separate subject, it's normally better to use elapsed milliseconds than Delay().

Yeah, i don't know, that,why don't my brain enough sharp, because i drunk to many or too little coffee. The Clock is on the 50 in the app


.

50 - too short. Set it to 200, set the Ardunio to 300. If that works, you can tweak the values down later (if required) .

General rule is that the time interval should be as long as possible but still meet the goal of the project. I once had a student who built a plant watering system with a time interval of 1000 ms - which of course was totally inappropriate, the interval should have been measured in hours or days.

Now i tried with this settings, and now better, but the Fail message stayed, only now do not always see on the Screen. I want to make a Joystick, for a FieldSprayer.

Try tweaking the values up, starting with the Arduino to 400. Also:

value = (String) value_pot0 + "," + (String) value_pot1;

try

value = (String) value_pot0 + "," + (String) value_pot1 + "\n";

Now, it can woking without Fail message, with this option:value = (String) value_pot0 + "," + (String) value_pot1 + "\n";

But now relativ slow, or it is slow for a Joystick. Yeah i know, for me, nothing is good.

Thanks for the many help.

You can tweak the values down again, I suspect the missing "\n" (= end of row) was the main issue. So App time interval = 160, Arduino = 200. (the App interval being 20% faster than the Arduino). Don't go back to 50 though.