e ai galera estou com problema no seguinte código a baixo:

ele roda normal só que quando clico em algum botão ligar ele liga mas não desliga sera que alguém poderia me ajudar não tenho muito conhecimento em programação

#include <LM35.h>
#include <SPI.h>
#include <Ethernet.h>


int led7 = 7;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led8 = 8;
int led9 = 9;

int pos = 0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 200 };
byte gateway[] = { 192, 168, 2, 1 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server(80);
String readString;

void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
pinMode(led7, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);

pinMode(led6, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);

Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}


void loop() {
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

if (readString.length() < 100) {
readString += c;
}

if (c == '\n') {
Serial.println(readString);
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
client.println("<TITLE>HOMESTAR</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>HOMESTAR</H1>");
client.println("<hr />");
client.println("<br />");
client.println("<H2>SALA</H2>");
client.println("<br />");
client.println("<a href=\"/?button7on\"\">Turn On LED</a>");
client.println("<a href=\"/?button7off\"\">Turn Off LED</a><br />");
client.println("<br />");
client.println("<a href=\"/?button2on\"\">Turn On LED</a>");
client.println("<a href=\"/?button2off\"\">Turn Off LED</a><br />");
client.println("<br />");
client.println("<a href=\"/?button3on\"\">Turn On LED</a>");
client.println("<a href=\"/?button3off\"\">Turn Off LED</a><br />");

client.println("<br />");
client.println("<a href=\"/?button4on\"\">Turn On LED</a>");
client.println("<a href=\"/?button4off\"\">Turn Off LED</a><br />");
client.println("<br />");
client.println("<a href=\"/?button5on\"\">Turn On LED</a>");
client.println("<a href=\"/?button5off\"\">Turn Off LED</a><br />");

client.println("<br />");
client.println("<a href=\"/?button6on\"\">Turn On LED</a>");
client.println("<a href=\"/?button6off\"\">Turn Off LED</a><br />");
client.println("<br />");
client.println("<a href=\"/?button8on\"\">Turn On LED</a>");
client.println("<a href=\"/?button8off\"\">Turn Off LED</a><br />");
client.println("<br />");
client.println("<a href=\"/?button9on\"\">Turn On LED</a>");
client.println("<a href=\"/?button9off\"\">Turn Off LED</a><br />");

client.println("<br />");
client.println("<br />");
client.println("<br />");
client.println("</BODY>");
client.println("</HTML>");

delay(2);
client.stop();
if (readString.indexOf("?button7on") >0){
digitalWrite(led7, HIGH);
}
if (readString.indexOf("?button7off") >0){
digitalWrite(led7, LOW);
}

if (readString.indexOf("?button2on") >0){
digitalWrite(led2, HIGH);
}
if (readString.indexOf("?button2off") >0){
digitalWrite(led2, LOW);
}




if (readString.indexOf("?button3on") >0){
digitalWrite(led3, HIGH);
}
if (readString.indexOf("?button3off") >0){
digitalWrite(led3, LOW);
}


if (readString.indexOf("?button4on") >0){
digitalWrite(led4, HIGH);
}
if (readString.indexOf("?button4off") >0){
digitalWrite(led4, LOW);
}

if (readString.indexOf("?button5on") >0){
digitalWrite(led5, HIGH);
}
if (readString.indexOf("?button5off") >0){
digitalWrite(led5, LOW);
}
if (readString.indexOf("?button6on") >0){
digitalWrite(led6, HIGH);
}
if (readString.indexOf("?button6off") >0){
digitalWrite(led6, LOW);
}
if (readString.indexOf("?button8on") >0){
digitalWrite(led8, HIGH);
}
if (readString.indexOf("?button8off") >0){
digitalWrite(led8, LOW);
}

if (readString.indexOf("?button9on") >0){
digitalWrite(led9, HIGH);
}
if (readString.indexOf("?button9off") >0){
digitalWrite(led9, LOW);
}

readString="";

}
}
}
}
}

Exibições: 559

Responder esta

Respostas a este tópico

Pessoal estou precisando de uma ajuda na programacao do arduino. Com ele conectado na ethernet eu preciso pegar uma informacao digitada no browser exemplo 192.168.0,200:8090/1 isso seria o ip do arduino depois a porta e o nr 1 apos a barra 'e a informacao que eu preciso extrair, como poderia fazer isso?

RSS

Destaques

Registre-se no
Lab de Garagem
Clicando aqui

Convide um
amigo para fazer
parte

curso gratis de arduino

© 2018   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço