Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
projets:esposc:accueil [2018/12/24 22:42] resonance [le projet] |
projets:esposc:accueil [2019/01/27 14:41] (Version actuelle) resonance [code] |
||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
* Contexte : | * Contexte : | ||
* Fichiers : lien | * Fichiers : lien | ||
- | * Lien : lien vers un site éventuellement | + | * Lien : d' |
Ligne 16: | Ligne 16: | ||
**Attention a bien choisir dans Outils dans Arduino (logiciel): | **Attention a bien choisir dans Outils dans Arduino (logiciel): | ||
- | * Wemos D1 R2 & mini | + | * Wemos D1 R2 & mini (apres avoir installer le driver ESP dans outils > ajouter carte) |
* baudrate 115200 | * baudrate 115200 | ||
Ligne 38: | Ligne 38: | ||
WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP | ||
- | const IPAddress outIp(192, | + | const IPAddress outIp(192, |
const unsigned int outPort = 9999; // remote port to receive OSC | const unsigned int outPort = 9999; // remote port to receive OSC | ||
const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) | const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) | ||
void setup() { | void setup() { | ||
- | pinMode(D1, INPUT_PULLUP); | + | pinMode(D1, INPUT_PULLUP); |
- | | ||
Serial.begin(115200); | Serial.begin(115200); | ||
Ligne 60: | Ligne 59: | ||
} | } | ||
Serial.println("" | Serial.println("" | ||
- | |||
Serial.println(" | Serial.println(" | ||
Serial.println(" | Serial.println(" | ||
Serial.println(WiFi.localIP()); | Serial.println(WiFi.localIP()); | ||
- | Serial.println(" | + | Serial.println(" |
Udp.begin(localPort); | Udp.begin(localPort); | ||
Serial.print(" | Serial.print(" | ||
Serial.println(Udp.localPort()); | Serial.println(Udp.localPort()); | ||
- | |||
} | } | ||
void loop() { | void loop() { | ||
+ | |||
+ | // on lit les valeurs A0 et D1 | ||
int sensorValue = analogRead(A0); | int sensorValue = analogRead(A0); | ||
- | int buttonState = digitalRead(D1); | + | |
| | ||
+ | // on cree un message OSC | ||
OSCMessage msg("/ | OSCMessage msg("/ | ||
- | | + | |
- | msg.add(buttonState); | + | msg.add(buttonState); |
Udp.beginPacket(outIp, | Udp.beginPacket(outIp, | ||
msg.send(Udp); | msg.send(Udp); | ||
Udp.endPacket(); | Udp.endPacket(); | ||
msg.empty(); | msg.empty(); | ||
- | delay(5); | + | delay(5); |
} | } | ||