Send message from Processing to Touch OSC Mk1 to update a led status

Oh OK. You said in the first post you were creating a custom MIDI controller. Didn’t read the rest of the thread, sorry!

This blinks the toggle button on your layout file. Note I’ve used a broadcast address for the ipad which is sometimes a bad idea for wifi.

import oscP5.*;

static final  NetAddress ipad = new NetAddress ("192.168.42.255", 9000);    // incoming port
OscP5 oscP5 = new OscP5 (this, 8000);      // set touchosc incoming port to this
OscMessage myMessage;
int time;
boolean toggle;

void setup() {
  
}

void draw() {
  if (millis() > time + 250) {
    time=millis();
    myMessage = new OscMessage("/1/toggle_button");
    if (toggle)
      myMessage.add (1.0);
    else
      myMessage.add (0.0);
    oscP5.send (myMessage, ipad);
    toggle=!toggle;
  }
}

Hi guys, was just checking out my post and just figured that I did not post the solution after all this time :frowning:
So here is the working solution :

 import oscP5.*;
 import netP5.*;
 OscP5 oscP5;
 NetAddress myRemoteLocation;
 float led = 1.0;
 void setup()
 {
   frameRate(25);
 oscP5 = new OscP5(this,8000);
 myRemoteLocation = new NetAddress("192.168.11.22",8020);

println("click in the window to toggle the LED");
 }

 void pushButtonFunction(float ledValue) {
   print("pushButtonFunction");
   print("value : " + ledValue);
 OscMessage myMessage = new OscMessage("/1/ledPink");
 myMessage.add(ledValue);
 oscP5.send(myMessage, myRemoteLocation);
 }
 void draw() {
   background(0);  
 }
 void keyPressed() {
   print("Key pressed ");
   pushButtonFunction(led);
   // toggle LED state for next time
   if(led == 0.0f) led = 1.0f; else led = 0.0f;
  
 }
 /* incoming osc message are forwarded to the oscEvent method. */
 void oscEvent(OscMessage theOscMessage) {
  
   if(theOscMessage.isPlugged()==false) {
   /* print the address pattern and the typetag of the received OscMessage */
 print("### received an osc message.");
 print(" addrpattern: "+theOscMessage.addrPattern());
 println(" typetag: "+theOscMessage.typetag());
   }
 }

remoteLocation = new NetAddress(“192.177.1.50”,8020);

The IP address in this variable have to equal to the Local IP address in the Touch OSC app to be able to send values at the launch of the sketch

The Network Host in the app have to be equal the Router address in the computer network settings.

Ex: 192.168.11.1

The Host in the app have to be equal to the IP Address of the computer network settings.

Ex: 192.168.11.8

I took some time to figure things out but I hope it could help someone.

1 Like