Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I'm using this simple code

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer server;

void setup() {
  Serial.begin(9600);
  Bridge.begin();
  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  YunClient client = server.accept();
  if (client) {
    Serial.println("client");
    process(client);
    client.stop();
   } else {
     Serial.println("no client");
   }
   delay(50); 
}

void process(YunClient client) {
  String command = client.readStringUntil('/');
  Serial.println(command);
  if (command == "turnLeft") {
    Serial.println("Gira a sinistra");
  }
  if (command == "turnRight") {
    Serial.println("Gira a destra");
  }
  if (command == "goTo") {
    String value = client.readStringUntil('/goTo/');
    Serial.println(value);
  }
}

but it seems to have problem with bridge (or server, or client, i cannot understand) because it only write "no client" on the serial.

I can not understand what is wrong.

Thanks a lot!

share|improve this question

2 Answers 2

I presume you are wanting the print output to show up on the Serial Monitor but you have connected the Arduino IDE to the Yun via the WiFi port on your network. If this is the case, then change all refs of Serial.print to Console.print This will direct the ASCII text to the Serial Monitor.

share|improve this answer

Probably too late to answer your question. Your problem is on line

if (client) 

Change it to

if(client.connected())

which actually returns true when client is connected.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.