Skip to content

Instantly share code, notes, and snippets.

@en129
Created February 20, 2022 09:38
Show Gist options
  • Save en129/85f3d306ee7031246fe6838209a40218 to your computer and use it in GitHub Desktop.
Save en129/85f3d306ee7031246fe6838209a40218 to your computer and use it in GitHub Desktop.
M5Atom-LiteのボタンからWiFi OSC経由でジャンプさせるだけ
#include "M5Atom.h"
// #define ARDUINOOSC_DEBUGLOG_ENABLE
#include <ArduinoOSCWiFi.h>
// WiFi stuff
const char* ssid = "yourSSID";
const char* pwd = "yourSSDIPassword";
//ESP32 IP address config
const IPAddress ip(192, 168, 11, 201);
const IPAddress gateway(192, 168, 11, 1);
const IPAddress subnet(255, 255, 255, 0);
// VRChat client PC IP address
const char* host = "192.168.11.10";
const int send_port = 9000;
void setup() {
M5.begin(true, false, true);
Serial.begin(115200);
delay(2000);
#ifdef ESP_PLATFORM
WiFi.disconnect(true, true); // disable wifi, erase ap info
delay(1000);
WiFi.mode(WIFI_STA);
#endif
WiFi.begin(ssid, pwd);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.print("WiFi connected, IP = ");
Serial.println(WiFi.localIP());
}
void loop() {
OscWiFi.update(); // should be called to receive + send osc
M5.update();
if(M5.Btn.wasPressed()){
M5.dis.drawpix(0, 0xf00000);
OscWiFi.send(host, send_port, "/input/Jump",1);
Serial.println("Jump 1");
}
else{
M5.dis.drawpix(0, 0x000000);
OscWiFi.send(host, send_port, "/input/Jump",0);
Serial.println("Jump 0");
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment