Go Down

Topic: Yun Server stops responding (Read 316 times) previous topic - next topic

AlbertJara

Hello everyone, I have a problem and I don't know how to solve it. I have an Arduino Yun with a web server to receive commands from the browser, the system works fine for the first 10 minutes, but then it starts to delay in the responses until it stops responding and does not respond either to the IP addresses of the device.

I leave the code

Code: [Select]

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

YunServer server;
String startString;
long hits = 0;
Servo servoMotorDosDerecha;

void setup() {

  Bridge.begin();

  pinMode(13,OUTPUT);

  Console.begin();

  server.listenOnLocalhost();
  server.begin();

  servoMotorDosDerecha.attach(6);

}

void loop() {

  YunClient client = server.accept();
 
  // There is a new client?
  if (client) {
    // read the command
    String command = client.readString();
    command.trim();        //kill whitespace
    client.println(command); // why does this return a full GET request instead of "on"?
    //servoMotorDosDerecha.write(0);

    if(command=="servo01")
    {
      servoMotorDosDerecha.write(100);
    }

    if(command=="servo02")
    {
      servoMotorDosDerecha.write(0);

    }

    if(command=="balizaOn")
    {
      digitalWrite(13,HIGH);
     
    }

    if(command=="balizaOff")
    {
      digitalWrite(13,LOW);
     
    }
   
    client.stop();
  }

}


Thanks for all your help :)

Go Up