Professional Documents
Culture Documents
U3 - Trabajo 1 - Leds
U3 - Trabajo 1 - Leds
#include <WiFi.h>
WiFiServer server(80);
String header;
// Current time
// Previous time
void setup() {
Serial.begin(115200);
pinMode(output26, OUTPUT);
pinMode(output27, OUTPUT);
pinMode(output25, OUTPUT);
pinMode(output33, OUTPUT);
digitalWrite(output26, LOW);
digitalWrite(output27, LOW);
digitalWrite(output25, LOW);
digitalWrite(output33, LOW);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
delay(500);
Serial.print(".");
Serial.println("");
Serial.println("WiFi connected.");
Serial.println(WiFi.localIP());
server.begin();
}
void loop(){
currentTime = millis();
previousTime = currentTime;
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected
currentTime = millis();
header += c;
// if the current line is blank, you got two newline characters in a row.
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
Serial.println("GPIO 26 on");
output26State = "on";
digitalWrite(output26, HIGH);
Serial.println("GPIO 26 off");
output26State = "off";
digitalWrite(output26, LOW);
Serial.println("GPIO 27 on");
output27State = "on";
digitalWrite(output27, HIGH);
Serial.println("GPIO 27 off");
output27State = "off";
digitalWrite(output27, LOW);
Serial.println("GPIO 25 on");
output25State = "on";
digitalWrite(output25, HIGH);
Serial.println("GPIO 25 off");
output25State = "off";
digitalWrite(output25, LOW);
Serial.println("GPIO 33 on");
output33State = "on";
digitalWrite(output33, HIGH);
Serial.println("GPIO 33 off");
output33State = "off";
digitalWrite(output33, LOW);
client.println("<!DOCTYPE html><html>");
// Feel free to change the background-color and font-size attributes to fit your preferences
client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
client.println(".button { background-color: #13F9BD; border: none; color: white; padding: 16px 40px;");
client.println("<body><h1>Zuleyma</h1>");
if (output26State=="off") {
} else {
if (output27State=="off") {
} else {
client.println("</body></html>");
if (output25State=="off") {
} else {
client.println("</body></html>");
if (output33State=="off") {
} else {
client.println("</body></html>");
client.println();
break;
currentLine = "";
} else if (c != '\r') { // if you got anything else but a carriage return character,
header = "";
client.stop();
Serial.println("Client disconnected.");
Serial.println("");