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.
serial.println(distance);
.