2014년 12월 5일 금요일

Problems with Split

I need help!
I have a Arduino Board and two sensors, a temperature sensor and pH sensor. Both sensors send one string information with pH and temperature, separated with a comma, by a Bluetooth module. Ex.: "11.20,23.00" (ph,temperature).
I must divide this string in two values. This two values I must insert in two differents constants (attributs). Ex.: 11.20 in pHValue and 23.00 in tempValue.
Anyone could help me please. How can I do this in MIT App Inventor 2? I'm very worried about this.



Try:





I put the "11.20,23.00"  in a label for the example.  Split converts the comma separate values and converts them to a List.  The list is converted to its components.

Does this work for you?



An erro has occorred. Did you ever see this? Follow bellow:












That value is missing a comma, so you're trying to get the second element of the list but the list only has one element.



It's done! Tnks guys!!!!

Tnks Enis and Steve!



It appears what you get from bluetooth is already a list ... your example  showed "11.20,23.00"   it appears what you are getting is (11.20,23.00)   which is already in list format.

Do a DoIt on you blocks to see what is happening.


댓글 없음:

댓글 쓰기