Touchosc not communicating with processing?

When I have my layout uploaded onto my iPod and I run the processing, whenever I move the faders up and down the processing faders on the computer screen don not move with me? Is there something that I am missing ?
thanks

import oscP5.*;
import netP5.*;

OscP5 oscP5;

float redAmount = 0.0f;
float greenAmount = 0.0f;
float blueAmount = 0.0f;


void setup () {
  size(320, 480);
  background(0);
  oscP5 = new OscP5(this,8000);
  
}


void draw (){
  background(redAmount, greenAmount, blueAmount);
  
  fill(0);
  //red rect
  stroke(255, 0, 0);
  rect(34,39,67,255);
  fill(50,40,40);
  rect(34,39+255,67,-redAmount);
  
  //green rect
  fill(0);
  stroke(0,255,0);
  rect(124,39,67,255);
  fill(40,50,40);
  rect(124,39+255,67,-greenAmount);
  
  //blue rect
  fill(0);
  stroke(0,0,255);
  rect(216,39,67,255);
  fill(40,40,50);
  rect(216,39+255,67,-blueAmount);
  
  
  
  
  
}

void oscEvent(OscMessage theOscMessage){
  String addr = theOscMessage.addrPattern();
  float val = theOscMessage.get(0).floatValue();
  
  if(addr.equals("/1/red")){ redAmount = val;}
  if(addr.equals("/1/green")){ greenAmount = val;}
  if(addr.equals("/1/blue")){ blueAmount = val;}



}

Is there something that I am missing ?

Some print statements to confirm what, if anything, is happening.

You get an addr, maybe. What is it?
You get a value, maybe. What is it?

A moment ago, it suddenly worked for some reason, then after about 20 seconds just stopped. Where will I see these values?

I followed this guys tutorial, and when I get to about 930 where he uploadeds it all layout/ and processing. It just isn't working.

Thanks for getting back to me :slight_smile:

look at my blog here: Digitalduino: TouchOSC with Processing, iPhone and Arduino.

Thanks for the post, would it be possible if you were able to tell me whats wrong with code I have. It's just that I am new with this, and with the code I have I already have the layout etc. Just want to change the RGB colours.

Like I say it work for a couple of seconds, but then just stopped?

Thanks

Is there something that I am missing ?

Maybe that this is an arduino forum not a processing or TouchOSC one.

However my guess is your settings. Have you tried using a fixed IP address at both ends?
I have some TouchOSC / processing code here:-
http://www.thebox.myzen.co.uk/Mac_Apps/Processing.html

Sorry, I thought I would as considering that I still am using the Arduino.

Thats the problem, I have the same IP address on both ipod and mac. But when I run the processing, it comes up with the layout. I get the layout on the ipod but nothing happens. I have tried most things but I still don’t know why it wont let me.

Can you help ?

I also tried yours, doesn't seem to be synced?

Thats the problem, I have the same IP address on both ipod and mac.

they need to be different but on the same network. You should never have two devices with the same IP address.

Can you take a look at the photos, have I got it right ?

Thanks

Screen shot 2012-04-19 at 17.33.42.png

I use the global variable

String iPadIP = "169.254.84.142"; // change this to the address of your iPad / iPhone

then in setup()
I use.

 /* start oscP5, listening for incoming messages at port 8000 */
  oscP5 = new OscP5(this,8000);
  // set the local IP address and port number to what is on the iPod
  myRemoteLocation = new NetAddress(iPadIP,8800); // local IP on the iPod  // select the correct page of the TouchOSC layout
  OscMessage myMessage = new OscMessage("/2");
  oscP5.send(myMessage, myRemoteLocation);

You need to set that string to the IP address of the iPod / pad.
You need to set the host IP address on the iPad to the address of your computer.

Thanks for the help,

Do I change this;

String addr = theOscMessage.addrPattern();

for this;

String iPadIP = "169.254.84.142"; // change this to the address of your iPad / iPhone

and where abouts do I put

/* start oscP5, listening for incoming messages at port 8000 */
  oscP5 = new OscP5(this,8000);
  // set the local IP address and port number to what is on the iPod
  myRemoteLocation = new NetAddress(iPadIP,8800); // local IP on the iPod  // select the correct page of the TouchOSC layout
  OscMessage myMessage = new OscMessage("/2");
  oscP5.send(myMessage, myRemoteLocation);

Thanks

I have just tried your code and I added a line to print all the messages from OSC

void oscEvent(OscMessage theOscMessage){
  String addr = theOscMessage.addrPattern();
  println(addr);  // uncomment for debug print of all recieved messages

And I get the correct messages sent. I haven't got the right TouchOSC page so I can only see the messages. Try adding that line as see if you get anything.

Hi, I think I have found out what is wrong with your code. The value returned is a float from 0 to 1, it needs to be multiplied by 255 to work. Change the receiving function to:-

void oscEvent(OscMessage theOscMessage){
  String addr = theOscMessage.addrPattern();
  println(addr);  // uncomment for debug print of all recieved messages

  float val = theOscMessage.get(0).floatValue();
  
  if(addr.equals("/1/red")){ redAmount = val*255;}
  if(addr.equals("/1/green")){ greenAmount = val*255;}
  if(addr.equals("/1/blue")){ blueAmount = val*255;}

}

Thank you very much for the help, I got it all working with the iPod and I even set up the LED. Th colours of the LED change a little, but not to the actual code im inputting. Is this due to the resistor I am using ?

thanks

Well we haven't see the code that transfers the numbers to the arduino, nor what the arduino does with it.
That said an LED has a totally different colour gamete than a screen so they won't match.