for a university Project I am trying to connect a touch board to Arena via OSC.
Aim is, that if an electrode gets touched a dedicated video gets played.
The Ardunio Code works just fine, but something in the Processing Sketch that should
send out the OSC to Arena does not really work. I can't get the OSC messages to be sent out.
Ardunio Code:
Code: Select all
// serial rate
#define baudRate 57600
#include <MPR121.h>
#include <Wire.h>
// this is the touch threshold - setting it low makes it more like a proximity trigger
// default value is 40 for touch
const int touchThreshold = 40;
// this is the release threshold - must ALWAYS be smaller than the touch threshold
// default value is 20 for touch
const int releaseThreshold = 20;
void setup(){
Serial.begin(baudRate);
while(!Serial); // only needed for Arduino Leonardo or Bare Touch Board
// 0x5C is the MPR121 I2C address on the Bare Touch Board
if(!MPR121.begin(0x5C)){
Serial.println("error setting up MPR121");
switch(MPR121.getError()){
case NO_ERROR:
Serial.println("no error");
break;
case ADDRESS_UNKNOWN:
Serial.println("incorrect address");
break;
case READBACK_FAIL:
Serial.println("readback failure");
break;
case OVERCURRENT_FLAG:
Serial.println("overcurrent on REXT pin");
break;
case OUT_OF_RANGE:
Serial.println("electrode out of range");
break;
case NOT_INITED:
Serial.println("not initialised");
break;
default:
Serial.println("unknown error");
break;
}
while(1);
}
MPR121.setTouchThreshold(touchThreshold);
MPR121.setReleaseThreshold(releaseThreshold);
}
void loop(){
readRawInputs();
}
void readRawInputs(){
int i;
if(MPR121.touchStatusChanged()) MPR121.updateTouchData();
MPR121.updateBaselineData();
MPR121.updateFilteredData();
Serial.print("");
for(i=0; i<12; i++){ // 13 touch values
Serial.print(MPR121.getTouchData(i), DEC);
if(i<12) Serial.print(" ");
}
Serial.println();
}
Code: Select all
//Die Bibliothek einbinden für das Lesen des seriellen Inputs
import processing.serial.*;
import oscP5.*;
import netP5.*;
final String host = "localhost";
final int portListening = 7001 ;
final int portSending = 7373;
OscP5 oscP5;
NetAddress OSCLocation;
OscBundle OSCBundle;
OscMessage OSCMessage;
final int baudRate = 300;
final String port = "/dev/cu.usbmodem1421";
final int lf = 10;
//Setzen der Variablen
Serial Microcontroller;
String input;
String[] electrodes;
//Setup
void setup()
{
//Die vordefinierten Variablen werden zugewiesen
Microcontroller = new Serial( this, port, baudRate );
Microcontroller.bufferUntil(lf);
oscP5 = new OscP5( this, 7001 );
OSCLocation = new NetAddress( host, 7373 );
OSCBundle = new OscBundle();
OSCMessage = new OscMessage("/");
OSCMessage.setAddrPattern( "/layer1/clip1/connect" );
OSCMessage.add( 1 );
OSCBundle.add( OSCMessage );
OSCMessage.clear();
oscP5.send( OSCBundle, OSCLocation );
}
//Draw (Brauchen wir nicht, kann man löschen, wenns kein Error gibt)
void draw() { }
void serialEvent( Serial p ) {
input = p.readString();
electrodes = splitTokens( input, " " );
updateOSC( electrodes );
}
void updateOSC( String[] electrodes ) {
String touchedElectrodes = "";
for ( int i = 0; i < electrodes.length; i++ ) {
int value = parseInt( electrodes[i] );
if ( value > 0 ) {
touchedElectrodes += i + " ";
}
}
if ( touchedElectrodes == "Unkown" ) {
OSCMessage.setAddrPattern( "/layer1/clip1/video/position/playmode" );
OSCMessage.add( 1 );
OSCBundle.add( OSCMessage );
OSCMessage.clear();
}
}
I'd be glad if someone could help me solve this problem.
Best,
Marco