#include <WiFi.h>
#include <WebServer.h>
// Configuración de la red WiFi
const char* ssid = "Galaxy A13 04B4";
const char* password = "12345678";
// Configuración del servidor web
WebServer server(80);
// Pin del potenciómetro
const int potPin = 32;
void setup() {
// Inicializar el monitor serial
Serial.begin(9600);
// Conectar a la red WiFi
Serial.print("Conectando a ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("Conectado a la red WiFi");
Serial.print("Dirección IP: ");
Serial.println(WiFi.localIP());
// Configurar el servidor web
server.on("/", handleRoot);
server.begin();
Serial.println("Servidor HTTP iniciado");
}
void loop() {
// Manejar las solicitudes del servidor web
server.handleClient();
}
void handleRoot() {
// Leer el valor del potenciómetro
int potValue = analogRead(potPin);
// Generar la respuesta HTML
String html = "<html><body><h1>Medición del Potenciómetro</h1>";
html += "<p>Valor: " + String(potValue) + "</p>";
html += "</body></html>";
// Enviar la respuesta al cliente
server.send(200, "text/html", html);
}