the 2nd part...
Processing sketch
/*
// importeer de volgende libraries serial,oscP5 en arduino classes voor communicatie met de arduino,IPOD en seriele verbinding.
import oscP5.*;
import netP5.*;
import processing.serial.*;
import cc.arduino.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Serial arduinoPort;
Arduino arduino;
int [] Toggle1 = new int [8];
int [] Toggle2 = new int [8];
int [] sliderStrip = new int [5];
float [] fader1 = new float [8];
float [] fader2 = new float [8];
boolean sliderNeedsRedraw = true;
int pwmMotorA,pwmMotorB = 0 ;
int EN1 = 12;
int EN2 = 11; //PWM uitgangen
int IN1 = 10;
int IN2 = 9; //Draairichting
int dirA,dirB= 0;
int laag =0;
int hoog =255;
int myMessage1 = 0;
int myMessage2 = 0;
int myMessage3 = 0;
int myMessage4 = 0;
int myMessage5 = 0;
int myMessage6 = 0;
void setup() {
size(290,360);
frameRate(25);
background(0);
fader1[1] = 0.5;
fader2[1] = 0.5;
/* start oscP5, listening for incoming messages at port 8000 */
oscP5 = new OscP5(this,8000);
myRemoteLocation = new NetAddress("192.168.62.55",9000); //IP address for outgoing data
arduinoPort = new Serial(this, "COM4", 9600); // Set arduino to 9600 baud
}
void oscEvent(OscMessage theOscMessage)
{
OscMessage myMessage1 = new OscMessage("/1/led1"); //used to store status of the motor
OscMessage myMessage2 = new OscMessage("/1/led2");
OscMessage myMessage3 = new OscMessage("/1/led3");
OscMessage myMessage4 = new OscMessage("/2/led1");
OscMessage myMessage5 = new OscMessage("/2/led2");
OscMessage myMessage6 = new OscMessage("/2/led3");
String addr = theOscMessage.addrPattern();
// println(addr); // uncomment for seeing the raw meshsage
//float val = theOscMessage.get(0).floatValue();
if(addr.indexOf("/1/fader") !=-1)
{ // one of the faders
String list[] = split(addr,'/');
int xfader = int(list[2].charAt(5) - 0x30);
fader1[xfader] = theOscMessage.get(0).floatValue();
// println(" x = "+fader[xfader]); // uncomment to see x values
sliderNeedsRedraw = true;
pwmMotorA=int(255*(fader1[1]));
}
if(addr.indexOf("/2/fader") !=-1)
{ // one of the faders
String list[] = split(addr,'/');
int xfader = int(list[2].charAt(5) - 0x30);
fader2[xfader] = theOscMessage.get(0).floatValue();
// println(" x = "+fader[xfader]); // uncomment to see x values
sliderNeedsRedraw = true;
pwmMotorB= int((255*(fader2[1])));
}
if(addr.indexOf("/1/toggle") !=-1)// the strip at the bottom
{
int i = int((addr.charAt(9) )) - 0x30; // retrns the ASCII number so convert into a real number by subtracting 0x30
String list[] = split(addr,'/');
Toggle1[i] = int(theOscMessage.get(0).floatValue());
// println(" i = "+i); // uncomment to see index value
sliderNeedsRedraw = true;
}
if(addr.indexOf("/2/toggle") !=-1)// the strip at the bottom
{
int i = int((addr.charAt(9) )) - 0x30; // retrns the ASCII number so convert into a real number by subtracting 0x30
String list[] = split(addr,'/');
Toggle2[i] = int(theOscMessage.get(0).floatValue());
// println(" i = "+i); // uncomment to see index value
sliderNeedsRedraw = true;
}
//bestuderen van de druktoetsen
if (Toggle1[2]==1)
{
dirA= '3';
myMessage1.add(0); /* add an int to the osc message */
myMessage2.add(0); /* add an int to the osc message */
myMessage3.add(1); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage1, myRemoteLocation);
oscP5.send(myMessage2, myRemoteLocation);
oscP5.send(myMessage3, myRemoteLocation);
}
else {
if(Toggle1[1] == 1)
{
dirA = '2';
myMessage1.add(0); /* add an int to the osc message */
myMessage2.add(1); /* add an int to the osc message */
myMessage3.add(0); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage1, myRemoteLocation);
oscP5.send(myMessage2, myRemoteLocation);
oscP5.send(myMessage3, myRemoteLocation);
}
else
{
dirA= '1';
myMessage1.add(1); /* add an int to the osc message */
myMessage2.add(0); /* add an int to the osc message */
myMessage3.add(0); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage1, myRemoteLocation);
oscP5.send(myMessage2, myRemoteLocation);
oscP5.send(myMessage3, myRemoteLocation);
}
}
if (Toggle2[2]==1)
{
dirB= '3';
myMessage4.add(0); /* add an int to the osc message */
myMessage5.add(0); /* add an int to the osc message */
myMessage6.add(1); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage4, myRemoteLocation);
oscP5.send(myMessage5, myRemoteLocation);
oscP5.send(myMessage6, myRemoteLocation);
}
else {
if(Toggle2[1] == 1)
{
dirB= '2';
myMessage4.add(0); /* add an int to the osc message */
myMessage5.add(1); /* add an int to the osc message */
myMessage6.add(0); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage4, myRemoteLocation);
oscP5.send(myMessage5, myRemoteLocation);
oscP5.send(myMessage6, myRemoteLocation);
}
else
{
dirB= '1';
myMessage4.add(1); /* add an int to the osc message */
myMessage5.add(0); /* add an int to the osc message */
myMessage6.add(0); /* add an int to the osc message */
/* send the message */
oscP5.send(myMessage4, myRemoteLocation);
oscP5.send(myMessage5, myRemoteLocation);
oscP5.send(myMessage6, myRemoteLocation);
}
}
arduinoPort.write(dirA); //send direction onto serialport
arduinoPort.write(dirB);
arduinoPort.write(pwmMotorA);
arduinoPort.write(pwmMotorB);
}
//here follows the code for drawing the slider and toggle buttons on the screen but i deleted it else couldnt post the sketch