Skip to main content

How to return the value in arundioArduino function (that can be read by the connectconnected device)?

Right now I have an RC car program of arundiofor Arduino. The code is like this:

void loop()
{ {
  distance = Dist.getDistanceCentimeter();
  if(distance<=5 & distance>1)
  if(Serial.available())
  {
    lkf = Serial.read();
  switch(lkf)
  {
  case 'a':
     forward();
     servoX.write(90);
     lkf=0; 
     break;    
  }
}

So I already writewrote a TCPcilentTCPclient that can order the RC car to move forward by connectconnecting through TCPTCP and sendsending the message "a" to the arundioArduino board.

The problem is how to return the distancedistance to the cilent? isIs it simply return distance; or something like system.println(distance);  ? Thanks for helping.

How to return the value in arundio function (that can be read by the connect device)?

Right now I have an RC car program of arundio. The code is like this:

void loop()
{ 
  distance = Dist.getDistanceCentimeter();
  if(distance<=5 & distance>1)
  if(Serial.available())
  {
    lkf = Serial.read();
  switch(lkf)
  {
  case 'a':
     forward();
     servoX.write(90);
     lkf=0; 
     break;    
  }
}

So I already write a TCPcilent that can order the RC car to move forward by connect through TCP and send the message "a" to the arundio board.

The problem is how to return the distance to the cilent? is it simply return distance; or something like system.println(distance);  ? Thanks for helping

How to return the value in Arduino function (that can be read by the connected device)?

Right now I have an RC car program for Arduino. The code is like this:

void loop() {
  distance = Dist.getDistanceCentimeter();
  if(distance<=5 & distance>1)
  if(Serial.available()) {
    lkf = Serial.read();
  switch(lkf) {
  case 'a':
     forward();
     servoX.write(90);
     lkf=0; 
     break;    
  }
}

I wrote a TCPclient that can order the RC car to move forward by connecting through TCP and sending the message "a" to the Arduino board.

The problem is how to return the distance to the cilent? Is it simply return distance; or something like system.println(distance);? Thanks for helping.

Post Migrated Here from electronics.stackexchange.com (revisions)
Source Link
user782104
  • 141
  • 1
  • 3
  • 7

How to return the value in arundio function (that can be read by the connect device)?

Right now I have an RC car program of arundio. The code is like this:

void loop()
{ 
  distance = Dist.getDistanceCentimeter();
  if(distance<=5 & distance>1)
  if(Serial.available())
  {
    lkf = Serial.read();
  switch(lkf)
  {
  case 'a':
     forward();
     servoX.write(90);
     lkf=0; 
     break;    
  }
}

So I already write a TCPcilent that can order the RC car to move forward by connect through TCP and send the message "a" to the arundio board.

The problem is how to return the distance to the cilent? is it simply return distance; or something like system.println(distance); ? Thanks for helping