#include #include // Remplacez par les informations de votre réseau WiFi const char* ssid = "Le chateau de Chantenay"; const char* password = "crevette4ever"; // Adresse du serveur HTTP sur le PC const char* host = "192.168.1.62"; // Remplacez par l'adresse IP de votre PC const int port = 5000; const int buttonPin = D7; // Définir le pin du bouton void setup() { Serial.begin(115200); delay(10); pinMode(buttonPin, INPUT_PULLUP); WiFi.begin(ssid, password); Serial.print("Connexion à "); Serial.print(ssid); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(" connectée"); } void loop() { if (digitalRead(buttonPin) == HIGH) { // Si le bouton est pressé Serial.println("Bouton pressé! Envoi de la requête..."); WiFiClient client; if (client.connect(host, port)) { client.print(String("GET /execute HTTP/1.1\r\n") + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); delay(500); // Attendre la réponse while (client.available()) { String line = client.readStringUntil('\r'); Serial.print(line); } client.stop(); } else { Serial.println("Échec de la connexion au serveur."); } } delay(100); // Attendre un peu avant de vérifier à nouveau }