07-13-2022, 11:55 PM
(This post was last modified: 07-14-2022, 12:05 AM by iliaslamprou.)
Hi,
you don't need to convert you integer or float values to Strings.
You have add code only here, it is very simple:
you don't need to convert you integer or float values to Strings.
You have add code only here, it is very simple:
Code:
String text1=""; //Declare some variable for the text. On Virtuino use the pin V32
String text2=""; // V33
String text3=""; // V34
//============================================================== onCommandReceived
//==============================================================
/* This function is called every time Virtuino app sends a request to server to change a Pin value
* The 'variableType' can be a character like V, T, O V=Virtual pin T=Text Pin O=PWM Pin
* The 'variableIndex' is the pin number index of Virtuino app
* The 'valueAsText' is the value that has sent from the app */
void onReceived(char variableType, uint8_t variableIndex, String valueAsText){
if (variableType=='V'){
float value = valueAsText.toFloat(); // convert the value to float. The valueAsText have to be numerical
if (variableIndex<V_memory_count) V[variableIndex]=value; // copy the received value to arduino V memory array
else if (variableIndex==32) text1=valueAsText; // V32 -> Text
else if (variableIndex==33) text2=valueAsText; // V33 -> Text
// else if (variableIndex==34) text3=valueAsText; // V34 ->Text
}
}
}
//==============================================================
/* This function is called every time Virtuino app requests to read a pin value*/
String onRequested(char variableType, uint8_t variableIndex){
if (variableType=='V') {
if (variableIndex<V_memory_count) return String(V[variableIndex]); // return the value of the arduino V memory array
else if (variableIndex==32) return text1; // V32 -> Text
else if (variableIndex==33) return text2; // V33 -> Text
// else if (variableIndex==34) return text3; // V34 ->Text
}
return "";
}