Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
|
projets:esp_32_bouton:start [2025/10/21 14:45] enseignant Créé depuis le formulaire creerunprojet |
projets:esp_32_bouton:start [2025/11/21 07:27] (Version actuelle) enseignant |
||
|---|---|---|---|
| Ligne 6: | Ligne 6: | ||
| ===== Note d' | ===== Note d' | ||
| - | Un systeme | + | Un système |
| - | {{@@Image@@? | + | L'esp crée un réseau wifi " |
| + | |||
| + | Il diffuse l' | ||
| + | {{: | ||
| + | |||
| + | |||
| + | |||
| + | <code c+> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // --- Configuration du WiFi Access Point --- | ||
| + | const char* ssid = " | ||
| + | const char* password = " | ||
| + | |||
| + | // --- Configuration OSC --- | ||
| + | const IPAddress broadcastIP(192, | ||
| + | const int remotePort = 8080; | ||
| + | |||
| + | WiFiUDP Udp; | ||
| + | |||
| + | // --- Broche du bouton | ||
| + | const int buttonPin = 2; | ||
| + | bool lastButtonState = HIGH; | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | |||
| + | // Démarre le point d' | ||
| + | Serial.println(" | ||
| + | WiFi.softAP(ssid, | ||
| + | |||
| + | IPAddress IP = WiFi.softAPIP(); | ||
| + | Serial.print(" | ||
| + | Serial.println(IP); | ||
| + | |||
| + | // Démarre UDP | ||
| + | Udp.begin(remotePort); | ||
| + | Serial.print(" | ||
| + | Serial.println(remotePort); | ||
| + | |||
| + | pinMode(buttonPin, | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | bool buttonState = digitalRead(buttonPin); | ||
| + | |||
| + | // Détection de front descendant (appui) | ||
| + | if (lastButtonState == HIGH && buttonState == LOW) { | ||
| + | Serial.println(" | ||
| + | |||
| + | // Crée un message OSC | ||
| + | OSCMessage msg("/ | ||
| + | msg.add(1); | ||
| + | |||
| + | // Envoi en broadcast | ||
| + | Udp.beginPacket(broadcastIP, | ||
| + | msg.send(Udp); | ||
| + | Udp.endPacket(); | ||
| + | msg.empty(); | ||
| + | | ||
| + | |||
| + | lastButtonState = buttonState; | ||
| + | delay(20); | ||
| + | } | ||
| + | </ | ||
| ==== Références et liens ==== | ==== Références et liens ==== | ||
| * Notez ici les références artistiques et techniques, ou autres influences | * Notez ici les références artistiques et techniques, ou autres influences | ||