Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
- byte ip[] = { 192, 168, 0, 188 }; // ip in lan
- byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
- byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
- EthernetServer server(8089); //server port
- String readString;
- //////////////////////
- void setup(){
- pinMode(28, OUTPUT); //pin selected to control
- //start Ethernet
- Ethernet.begin(mac, ip, gateway, gateway, subnet);
- server.begin();
- //enable serial data print
- Serial.begin(9600);
- Serial.println("server multi pin button 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("<HTML>");
- client.println("<HEAD>");
- client.println("<TITLE>Arduino</TITLE>");
- client.println("</HEAD>");
- client.println("<BODY>");
- client.println("<br>");
- client.println("<br>");
- client.println("<H1><center>POR FAVOR ME AJUDA NESSE PROJETO </center></H1>");
- client.println("<br>");
- client.println("<br>");
- client.println("<H1><center>PARA LIGAR O LED E PRECISO MANTER PRESSIONADO O BOTAO</center></H1>");
- client.println("<H1><center>PARA DESLIGAR O LED SOLTE O BOTAO </center></H1>");
- client.println("<br>");
- // custom buttons
- client.println("<div><table align='center' border=30 ><th><h7>");
- client.print("<input type=submit value=PRESSIONE style=width:200px;height:90px onClick=location.href='/?on28;'>");
- client.println("</div></table>");
- client.println("</BODY>");
- client.println("</HTML>");
- delay(1);
- //stopping client
- client.stop();
- if(readString.indexOf('8') >0)//checks for 8
- {
- digitalWrite(28, HIGH); // set pin 8 high
- Serial.println("Led 8 On");
- }
- if(readString.indexOf('8') <0)//checks for 8
- {
- digitalWrite(28, LOW); // set pin 8 low
- Serial.println("Led 8 Off");
- }
- //clearing string for next read
- readString="";
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement