7 changed files with 428 additions and 41 deletions
@ -0,0 +1,129 @@ |
|||||
|
|
||||
|
#include <Wire.h> |
||||
|
#include <ESP8266WiFi.h> |
||||
|
#include <WiFiUdp.h> |
||||
|
#include <OSCMessage.h> |
||||
|
#include <SPI.h> |
||||
|
|
||||
|
const int MPU=0x68; |
||||
|
int16_t AcX,AcY,AcZ; |
||||
|
|
||||
|
char ssid[] = "NETGEAR41"; |
||||
|
char pass[] = "magicalbanana0"; |
||||
|
|
||||
|
WiFiUDP Udp; |
||||
|
const IPAddress outIp(192,168,0,29); // remote IP of receiver computer
|
||||
|
const unsigned int outPort = 7000; // remote port to receive OSC
|
||||
|
|
||||
|
|
||||
|
int fingerGround = 15; |
||||
|
int fingerSignal = 18; |
||||
|
int finger1 = 16; |
||||
|
int finger2 = 14; |
||||
|
int finger3 = 12; |
||||
|
int finger4 = 13; |
||||
|
|
||||
|
void setup() { |
||||
|
|
||||
|
Wire.begin(); |
||||
|
Wire.beginTransmission(MPU); |
||||
|
Wire.write(0x6B); |
||||
|
Wire.write(0); |
||||
|
Wire.endTransmission(true); |
||||
|
|
||||
|
Serial.begin(115200); |
||||
|
|
||||
|
Serial.print("Connecting to "); |
||||
|
Serial.println(ssid); |
||||
|
WiFi.begin(ssid, pass); |
||||
|
|
||||
|
while (WiFi.status() != WL_CONNECTED) { |
||||
|
delay(500); |
||||
|
Serial.print("."); |
||||
|
} |
||||
|
|
||||
|
Serial.println(""); |
||||
|
Serial.println("WiFi connected"); |
||||
|
Serial.println("IP address: "); |
||||
|
Serial.println(WiFi.localIP()); |
||||
|
|
||||
|
pinMode(fingerSignal, OUTPUT); |
||||
|
pinMode(fingerGround, OUTPUT); |
||||
|
digitalWrite(fingerSignal, HIGH); |
||||
|
digitalWrite(fingerGround, LOW); |
||||
|
|
||||
|
pinMode(finger1, INPUT); |
||||
|
pinMode(finger2, INPUT); |
||||
|
pinMode(finger3, INPUT); |
||||
|
pinMode(finger4, INPUT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void loop() { |
||||
|
|
||||
|
Wire.beginTransmission(MPU); |
||||
|
Wire.write(0x3B); |
||||
|
Wire.endTransmission(false); |
||||
|
Wire.requestFrom(MPU,14); |
||||
|
AcX=Wire.read()<<8|Wire.read(); |
||||
|
AcY=Wire.read()<<8|Wire.read(); |
||||
|
AcZ=Wire.read()<<8|Wire.read(); |
||||
|
|
||||
|
Serial.print(AcX); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(AcY); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger1)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger2)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger3)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger4)); |
||||
|
Serial.println("\t"); |
||||
|
//Serial.println(AcZ);
|
||||
|
|
||||
|
OSCMessage msgLX("/movedulation/sliderLX"); |
||||
|
msgLX.add(AcX); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgLX.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgLX.empty(); |
||||
|
|
||||
|
OSCMessage msgLY("/movedulation/sliderLY"); |
||||
|
msgLY.add(AcY); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgLY.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgLY.empty(); |
||||
|
|
||||
|
OSCMessage msgL1("/movedulation/toggleL1"); |
||||
|
msgL1.add(digitalRead(finger1)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgL1.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgL1.empty(); |
||||
|
|
||||
|
OSCMessage msgL2("/movedulation/toggleL2"); |
||||
|
msgL2.add(digitalRead(finger2)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgL2.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgL2.empty(); |
||||
|
|
||||
|
OSCMessage msgL3("/movedulation/toggleL3"); |
||||
|
msgL3.add(digitalRead(finger3)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgL3.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgL3.empty(); |
||||
|
|
||||
|
OSCMessage msgL4("/movedulation/toggleL4"); |
||||
|
msgL4.add(digitalRead(finger4)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgL4.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgL4.empty(); |
||||
|
|
||||
|
delay(100); |
||||
|
} |
@ -0,0 +1,129 @@ |
|||||
|
|
||||
|
#include <Wire.h> |
||||
|
#include <ESP8266WiFi.h> |
||||
|
#include <WiFiUdp.h> |
||||
|
#include <OSCMessage.h> |
||||
|
#include <SPI.h> |
||||
|
|
||||
|
const int MPU=0x68; |
||||
|
int16_t AcX,AcY,AcZ; |
||||
|
|
||||
|
char ssid[] = "NETGEAR41"; |
||||
|
char pass[] = "magicalbanana0"; |
||||
|
|
||||
|
WiFiUDP Udp; |
||||
|
const IPAddress outIp(192,168,0,29); // remote IP of receiver computer
|
||||
|
const unsigned int outPort = 7000; // remote port to receive OSC
|
||||
|
|
||||
|
|
||||
|
int fingerGround = 15; |
||||
|
int fingerSignal = 18; |
||||
|
int finger1 = 16; |
||||
|
int finger2 = 14; |
||||
|
int finger3 = 12; |
||||
|
int finger4 = 13; |
||||
|
|
||||
|
void setup() { |
||||
|
|
||||
|
Wire.begin(); |
||||
|
Wire.beginTransmission(MPU); |
||||
|
Wire.write(0x6B); |
||||
|
Wire.write(0); |
||||
|
Wire.endTransmission(true); |
||||
|
|
||||
|
Serial.begin(115200); |
||||
|
|
||||
|
Serial.print("Connecting to "); |
||||
|
Serial.println(ssid); |
||||
|
WiFi.begin(ssid, pass); |
||||
|
|
||||
|
while (WiFi.status() != WL_CONNECTED) { |
||||
|
delay(500); |
||||
|
Serial.print("."); |
||||
|
} |
||||
|
|
||||
|
Serial.println(""); |
||||
|
Serial.println("WiFi connected"); |
||||
|
Serial.println("IP address: "); |
||||
|
Serial.println(WiFi.localIP()); |
||||
|
|
||||
|
pinMode(fingerSignal, OUTPUT); |
||||
|
pinMode(fingerGround, OUTPUT); |
||||
|
digitalWrite(fingerSignal, HIGH); |
||||
|
digitalWrite(fingerGround, LOW); |
||||
|
|
||||
|
pinMode(finger1, INPUT); |
||||
|
pinMode(finger2, INPUT); |
||||
|
pinMode(finger3, INPUT); |
||||
|
pinMode(finger4, INPUT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void loop() { |
||||
|
|
||||
|
Wire.beginTransmission(MPU); |
||||
|
Wire.write(0x3B); |
||||
|
Wire.endTransmission(false); |
||||
|
Wire.requestFrom(MPU,14); |
||||
|
AcX=Wire.read()<<8|Wire.read(); |
||||
|
AcY=Wire.read()<<8|Wire.read(); |
||||
|
AcZ=Wire.read()<<8|Wire.read(); |
||||
|
|
||||
|
Serial.print(AcX); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(AcY); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger1)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger2)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger3)); |
||||
|
Serial.print("\t"); |
||||
|
Serial.print(digitalRead(finger4)); |
||||
|
Serial.println("\t"); |
||||
|
//Serial.println(AcZ);
|
||||
|
|
||||
|
OSCMessage msgRX("/movedulation/sliderRX"); |
||||
|
msgRX.add(AcX); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgRX.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgRX.empty(); |
||||
|
|
||||
|
OSCMessage msgRY("/movedulation/sliderRY"); |
||||
|
msgRY.add(AcY); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgRY.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgRY.empty(); |
||||
|
|
||||
|
OSCMessage msgR1("/movedulation/toggleR1"); |
||||
|
msgR1.add(digitalRead(finger1)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgR1.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgR1.empty(); |
||||
|
|
||||
|
OSCMessage msgR2("/movedulation/toggleR2"); |
||||
|
msgR2.add(digitalRead(finger2)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgR2.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgR2.empty(); |
||||
|
|
||||
|
OSCMessage msgR3("/movedulation/toggleR3"); |
||||
|
msgR3.add(digitalRead(finger3)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgR3.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgR3.empty(); |
||||
|
|
||||
|
OSCMessage msgR4("/movedulation/toggleR4"); |
||||
|
msgR4.add(digitalRead(finger4)); |
||||
|
Udp.beginPacket(outIp, outPort); |
||||
|
msgR4.send(Udp); |
||||
|
Udp.endPacket(); |
||||
|
msgR4.empty(); |
||||
|
|
||||
|
delay(100); |
||||
|
} |
Binary file not shown.
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 296 KiB |
@ -1,27 +0,0 @@ |
|||||
|
|
||||
import oscP5.*; |
|
||||
import netP5.*; |
|
||||
|
|
||||
OscP5 oscP5; |
|
||||
|
|
||||
void setup() { |
|
||||
size(400,400); |
|
||||
frameRate(25); |
|
||||
oscP5 = new OscP5(this,7000); |
|
||||
} |
|
||||
|
|
||||
void draw() { |
|
||||
background(0); |
|
||||
} |
|
||||
|
|
||||
void oscEvent(OscMessage theOscMessage) { |
|
||||
print("### Pattern: "+theOscMessage.addrPattern()); |
|
||||
print(" TypeTag:"+theOscMessage.typetag()); |
|
||||
if(theOscMessage.checkTypetag("i")){ |
|
||||
print(" Value: "+theOscMessage.get(0).intValue()); |
|
||||
} |
|
||||
if(theOscMessage.checkTypetag("s")){ |
|
||||
print(" Value: "+theOscMessage.get(0)); |
|
||||
} |
|
||||
println(); |
|
||||
} |
|
@ -0,0 +1,105 @@ |
|||||
|
|
||||
|
import oscP5.*; |
||||
|
import netP5.*; |
||||
|
|
||||
|
int sliderRX = 0; |
||||
|
int sliderRY = 0; |
||||
|
int sliderLX = 0; |
||||
|
int sliderLY = 0; |
||||
|
int fingersR[] = {0, 0, 0, 0}; |
||||
|
int fingersL[] = {0, 0, 0, 0}; |
||||
|
|
||||
|
OscP5 oscP5; |
||||
|
|
||||
|
void setup() { |
||||
|
size(400, 250); |
||||
|
frameRate(25); |
||||
|
oscP5 = new OscP5(this, 7000); |
||||
|
} |
||||
|
|
||||
|
void draw() { |
||||
|
background(0); |
||||
|
fill(255); |
||||
|
stroke(255); |
||||
|
strokeWeight(4); |
||||
|
|
||||
|
line(100, 25, 100, 175); |
||||
|
line(25, 100, 175, 100); |
||||
|
circle(100, map(sliderLY, -16000, 16000, 25, 175), 20); |
||||
|
circle(map(sliderLX, -16000, 16000, 175, 25), 100, 20); |
||||
|
|
||||
|
line(300, 25, 300, 175); |
||||
|
line(225, 100, 375, 100); |
||||
|
circle(300, map(sliderRY, -16000, 16000, 25, 175), 20); |
||||
|
circle(map(sliderRX, -16000, 16000, 375, 225), 100, 20); |
||||
|
|
||||
|
fill(fingersL[0] == 1 ? 255 : 0); |
||||
|
circle(40, 210, 20); |
||||
|
fill(fingersL[1] == 1 ? 255 : 0); |
||||
|
circle(80, 210, 20); |
||||
|
fill(fingersL[2] == 1 ? 255 : 0); |
||||
|
circle(120, 210, 20); |
||||
|
fill(fingersL[3] == 1 ? 255 : 0); |
||||
|
circle(160, 210, 20); |
||||
|
|
||||
|
fill(fingersR[0] == 1 ? 255 : 0); |
||||
|
circle(240, 210, 20); |
||||
|
fill(fingersR[1] == 1 ? 255 : 0); |
||||
|
circle(280, 210, 20); |
||||
|
fill(fingersR[2] == 1 ? 255 : 0); |
||||
|
circle(320, 210, 20); |
||||
|
fill(fingersR[3] == 1 ? 255 : 0); |
||||
|
circle(360, 210, 20); |
||||
|
} |
||||
|
|
||||
|
void oscEvent(OscMessage theOscMessage) { |
||||
|
if(theOscMessage.checkTypetag("i")){ |
||||
|
switch(theOscMessage.addrPattern()) { |
||||
|
case "/movedulation/sliderRX": |
||||
|
sliderRX = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/sliderRY": |
||||
|
sliderRY = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/sliderLX": |
||||
|
sliderLX = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/sliderLY": |
||||
|
sliderLY = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
|
||||
|
case "/movedulation/toggleR1": |
||||
|
fingersR[0] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleR2": |
||||
|
fingersR[1] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleR3": |
||||
|
fingersR[2] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleR4": |
||||
|
fingersR[3] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
|
||||
|
case "/movedulation/toggleL1": |
||||
|
fingersL[0] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleL2": |
||||
|
fingersL[1] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleL3": |
||||
|
fingersL[2] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
case "/movedulation/toggleL4": |
||||
|
fingersL[3] = theOscMessage.get(0).intValue(); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
//if(theOscMessage.checkTypetag("i")){ |
||||
|
//println(" Value: "+theOscMessage); |
||||
|
//} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue