Olá pessoal,
Fiz um servidor web para controlar uma placa de relés através de um navegador
porem só consigo “pingar” e acessar o navegador se eu ligar o cabo ethernet diretamente na porta do ethernet computador. Quando eu ponho um Switch entre eles, os pings param e nao consigo mais acessar a pag web
estou usando ip estatico na interface LAN do PC. Já troquei os cabos. as luzes do switch acendem identificando o dispositivo. Não sei mais o que fazer me ajudem. obrigado pela atenlção.
> #include <SPI.h>
> #include <Ethernet.h>
>
> boolean statop1 = false;
> boolean statop2 = false;
> boolean statop3 = false;
> boolean statop4 = false;
> byte mac[] = { 0xDC, 0x9D, 0xDB, 0xEF, 0xFE, 0xED }; //physical mac address
> byte ip[] = { 172, 16, 1, 200 }; // ip in lan
> byte gateway[] = { 172, 16, 1, 1 }; // internet access via router
> byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
> EthernetServer server(80); //server port
>
> String readString;
>
> /
>
> void setup(){
>
> pinMode(7, OUTPUT); //pin selected to control
> pinMode(6, OUTPUT); //pin selected to control
> pinMode(5, OUTPUT); //pin selected to control
> pinMode(4, OUTPUT); //pin selected to control
> //start Ethernet
> Ethernet.begin(mac, ip, gateway, subnet);
> server.begin();
> Serial.begin(9600);
> Serial.println("Domotic Server test 1.0"); // so I can keep track of what is loaded
> }
>
> void loop(){
> // Create a client connection
> EthernetClient client = server.available();
> if (client) {
> while (client.connected()) {
> if (client.available()) {
> char c = client.read();
>
> //read char by char HTTP request
> if (readString.length() < 100) {
>
> //store characters to string
> readString += c;
> //Serial.print(c);
> }
>
> //if HTTP request has ended
> if (c == '\n') {
>
> //
> Serial.println(readString); //print to serial monitor for debuging
>
> client.println("HTTP/1.1 200 OK"); //send new page
> client.println("Content-Type: text/html");
> client.println();
>
> client.println("<!DOCTYPE html><html><head><meta name='apple-mobile-web-app-capable' content='yes'><meta name='apple-mobile-web-app-status-bar-style' content='black-translucent'><link rel='stylesheet' type='text/css' href='http://homeautocss.net84.net/a.css'><TITLE>Controle de Reboot Choró</TITLE></HEAD><BODY><H1>Controle Reboot Choro Limao</H1><hr><br><ul><li><p align=\"left\">REDE 1:<a href=\"/?light1on\">_LIGAR </a><a href=\"/?light1off\">_DESLIGAR</a></li></p><br><br><li><p align=\"left\">REDE 2_:<a href=\"/?light2on\">_LIGAR</a><a href=\"/?light2off\">_DESLIGAR</a></li></p><br><br><li><p align=\"left\">REDE 3:<a href=\"/?light3on\">_LIGAR</a><a href=\"/?light3off\">_DESLIGAR</a></li></p><br><br><li><p align=\"left\">_REDE 4:<a href=\"/?light4on\">_LIGAR</a><a href=\"/?light4off\">_DESLIGAR</a></li></p><br><br></ul></BODY></HTML>");
>
> delay(1);
> //stopping client
> client.stop();
>
> // control arduino pin
> if(readString.indexOf("?light1on") >0)//checks for on
> {
> statop1 = true;
> }
> if(readString.indexOf("?light1off") >0)//checks for off
> {
> statop1 = false;
> }
> if(readString.indexOf("?light2on") >0)//checks for on
> {
> statop2 = true;
> }
> if(readString.indexOf("?light2off") >0)//checks for off
> {
> statop2 = false;
> }
> if(readString.indexOf("?light3on") >0)//checks for on
> {
> statop3 = true;
> }
> if(readString.indexOf("?light3off") >0)//checks for off
> {
> statop3 = false;
> }
> if(readString.indexOf("?light4on") >0)//checks for on
> {
> statop4 = true;
> }
> if(readString.indexOf("?light4off") >0)//checks for off
> {
> statop4 = false;
> }
>
>
> if(statop1 == true)
> {
> digitalWrite(7, LOW);
> }
> if(statop1 == false)
> {
> digitalWrite(7, HIGH);
> }
> if(statop2 == true)
> {
> digitalWrite(6, LOW);
> }
> if(statop2 == false)
> {
> digitalWrite(6, HIGH);
> }
> if(statop3 == true)
> {
> digitalWrite(5, LOW);
> }
> if(statop3 == false)
> {
> digitalWrite(5, HIGH);
> }
> if(statop4 == true)
> {
> digitalWrite(4, LOW);
> }
> if(statop4 == false)
> {
> digitalWrite(4, HIGH);
> }
> //clearing string for next read
> readString="";
>
> }
> }
> }
> }
> }