Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
send receive TEXT Virtuino6 VirtuinoCN
#2
Hi, this is an example for the Ethernet connection.
The only you have to do is to change the connection type lines.
https://virtuino.com/downloads/examples/...e_text.zip

On the top of the code declare two Strings:
String T0="";
String T1="";

On the void loop do something with the strings:
if (T0=="ENABLE PIN 5") digitalWrite(5,HIGH);
  else if (T0=="DISABLE PIN 5") digitalWrite(5,LOW);
 
  T1= "Hello Virtuino "+String(random(100));


Make these changes to the onReceived and onRequested methods 
Code:
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 (variableType=='T'){
      if (variableIndex==0) T0=valueAsText;          // Store the text to the text variable T0
      else if (variableIndex==1) T1=valueAsText;     // Store the text to the text variable T1
     //else if (variableIndex==2) T2=valueAsText;     // Store the text to the text variable T2
     //else if (variableIndex==3) T3=valueAsText;     // Store the text to the text variable T3
     
    }
}

String onRequested(char variableType, uint8_t variableIndex){    
Code:
    if (variableType=='V') {
Code:
    if (variableIndex<V_memory_count) return  String(V[variableIndex]);   // return the value of the arduino V memory array
Code:
  }
Code:
  else if (variableType=='T') {
Code:
   if (variableIndex==0) return T0; 
Code:
   else if (variableIndex==1) return T1;  
Code:
   //else if (variableIndex==2) return T2;  
Code:
   //else if (variableIndex==3) return T3;  
Code:
   }
Code:
  
Code:
  return "";
Code:
}
Reply


Messages In This Thread
RE: send receive TEXT Virtuino6 VirtuinoCN - by iliaslamprou - 01-29-2024, 07:50 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)