Why are my processing and Arduino not communicating??

I am trying to use processing to communicate between my arduino and my Iphone. I know the phone is communicating with the procssing. And i know the arduino is working to turn on my El wire. But for some reason the Arduino serial port is either not writing on processing side or not reading on arduino side. Please help. I am a bit of a novice and just cannot find where the problem is.
Here is the code I have used, would really appreciate if anyone could point me in the right direction. :slight_smile:

--------------------Arduino------------------------

int message = 0;

void elSegment(byte num, boolean value) {
digitalWrite(num + 2, value ? HIGH : LOW);
}

void setup() {
byte pin;
for (pin = 2; pin < 10; pin++) {
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
Serial.begin(9600);
}
}

void loop() {
if (Serial.available() > 0) {
message = Serial.read();
}
if (message == 'R'){
elSegment(1, false);
}
if (message == 'r'){
elSegment(1, true);
}
}
--------------------ArduinoEnd------------------------

--------------------Processing-------------------------
import oscP5.;
import netP5.
;
import processing.serial.*;
Serial arduinoPort;
OscP5 oscP5;

int redLED = 0;
int [] led = new int [2];

void setup() {
size(100,100);
noStroke();
oscP5 = new OscP5(this,8000);
arduinoPort = new Serial(this, Serial.list()[0], 9600);
}

void oscEvent(OscMessage theOscMessage) {
String addr = theOscMessage.addrPattern();
if(addr.indexOf("/1/toggle") !=-1){
int i = int((addr.charAt(9) )) - 0x30;
led* = int(theOscMessage.get(0).floatValue()); *

  • }*
    }
    void draw() {
    *background(50); *
  • if(led[1] == 0){ *
  • arduinoPort.write("r"); *
  • redLED = 0; *
  • }*
    *if(led[1] == 1){ *
  • arduinoPort.write("R");*
  • redLED = 255; *
  • }*
    *fill(redLED,0,0); *
  • ellipse(50, 50, 50, 50); *
    }
    --------------------ProcessingEnd-------------------------
arduinoPort = new Serial(this, Serial.list()[0], 9600);

Are you sure that the Arduino is connected to the first COM port in the list?

COM4! Opse!! Thank you for your help. All up and working now :slight_smile: knew it was something simple.