Bonjour !
Je suis débutant (a peine 3 mois), merci par avance de votre indulgence
Je bloque sur un problème de fonction...
J'aimerai transformer ceci en fonction (car cela se répète plus de 20 fois juste en modifiant "digitalRead", "boutonRelacheD..." "etatD..." ):
Résultat: après de nombreux tests, j'arrive a me "bricoler" une fonction qui marche bien avec Serial.print, mais toute la partie connexion réseau
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 if (digitalRead(2) == HIGH) { // PULLUP = le bouton est relâché en HIGH //// DIGITAL 1 SUR PIN 2 //// if (!boutonRelacheD1) { boutonRelacheD1 = true; Ethernet.begin(mac, ip, subnet, gateway); if (client.connect(ipx, 80)) { Serial.println("TEST OFF"); client.println("GET /control.json?SystemOFF=001 HTTP/1.0"); client.println("Host: 192.168.1.100"); client.println("Connection: close"); client.println(); client.stop(); } } } else { // le bouton est appuyé. est-ce un nouvel appui? if (boutonRelacheD1) { // le bouton n'était pas appuyé avant -> nouvel appui, on inverse l'état boutonRelacheD1 = false; etatD1 = (etatD1 == HIGH) ? LOW : HIGH; // etat = 1 - etat; Ethernet.begin(mac, ip, subnet, gateway); if (client.connect(ipx, 80)) { Serial.println("TEST ON"); client.println("GET /control.json?SystemON=001 HTTP/1.0"); client.println("Host: 192.168.1.100"); client.println("Connection: close"); client.println(); client.stop(); } } }
est ignorée, pourquoi ? Est-il possible de mettre des fonctions réseaux dans une fonction ?
Merci beaucoup pour vos lumières !!!!
Thierry
Partager