readin multiple analog sensors?

Hi, I'm new at arduino. So far with some help and a lot of research I have managed to get my arduino talking to flash using a light sensor or a potentiometer.

The code in the environment reading in this case from a light sensor is this:

[processing code start]

int firstSensor = 0; // first analog sensor
void setup()
{

Serial.begin(9600);
}
void loop()
{
firstSensor = analogRead(0);
delay(10);
Serial.print(firstSensor, DEC);
Serial.print(0, BYTE);

delay (50);
}
[processing code end]

The code in the serproxy config file is this:
[serproxy code start]

Config file for serproxy

See serproxy's README file for documentation

Transform newlines coming from the serial port into nils

true (e.g. if using Flash) or false

newlines_to_nils=true

#The USB port that the Arduino is connected to
serial_device1=/dev/tty.usbserial-A60049Co

#Comm ports used
comm_ports=1,2,3,4

***set the baud rate

comm_baud=9600

#Default settings
comm_databits=8
comm_stopbits=1
comm_parity=none

Idle time out in seconds

timeout=300

Port 1 settings (ttyS0)

net_port1=5334

Port 2 settings (ttyS1)

net_port2=5332

Port 3 settings (ttyS2)

#net_port3=5333

Port 4 settings (ttyS3)

net_port4=5331
[serproxy code end]

The flash actionscript code is this:
[flash as code start]
createSocket ();

function createSocket () {

serialServer = new XMLSocket ();
trace ("made it" + serialServer);
//127.0.0.1 is the same as "localhost" ie an alias to your local machine
//it is concievable to that you would want to connect from another machine and you would change this
serialServer.connect ("127.0.0.1", 5331);
serialServer.onConnect = function (success) {
trace ("connected " + success);
serialServer.send ("HOWDY FROM FLASH" + new Date().toString());
};

serialServer.onClose = function () {
trace ("closed");
};

serialServer.onData = function (data) {
trace ("incoming" + data);
test = data;
test = Math.round((data / 4)*2 );
test = test /10
trace (test);

_root.ball._xscale = test;//scale the ball based on the changing variable.
_root.ball._yscale = test;
_root.output1_txt.text = ("test" + test);
_root.output2_txt.text=("serialServer" + serialServer);
_root.output3_txt.text=("incoming data" + data);
//mcpos = Math.round(data / 100 *2);
//mc1.gotoAndStop(mcpos);
//trace (mcpos);
};

}
[flash as code end]

This works just fine and I can control an animation by the numbers read from the sensors. The problem I'm having now is getting more than one sensor controlling more than one animation i.e. each individual sensor controls a seperate animation. I have researched and cannot find any specific examples to help me and I have tried coding flash and processing with disastrous nonsensical results.

Has anyone any experience or solutions to this? I'm not sure whether I should be trying to work on the serproxy config, the flash code, processing code etc or even if it's a combination (which I'm sure it is, but can't at the moment get my head around the logic). Any help is appreciated on this, I'll put up further info if needed. Thanks very much for any help.

If you are using more than one sensor you have to identify what sensor each reading corresponds to. So for example at the Arduino end you might prefix one sensor reading with the letter "A" and the other with the letter "B".

Then at the receiving end you have to route the correct data to the correct action. This will involve some code at the receiving end to identify what data you have and to hit the correct code with it.

Doing this is called a "protocol" and you can make them up as long as you are in control of both the sending and receiving end. When you want someone else to do one end you have to know the "protocol" so you can match it.

Thanks Mike: I'm working away on that at the moment but my programming skills are poor enough. What I have done so far is:

ARDUINO CODE.
int firstSensor = 2; // lightsensor
int secondSensor = 3; //potentiometer
int test1=0;
int test2=0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
test1=analogRead(firstSensor);
delay(10);
test2=analogRead(secondSensor);
delay(10);

Serial.print("A"); //potentiometer REading
delay(10);
Serial.print(test2, DEC);
Serial.print(0,BYTE);

Serial.print("B");//lightSensor REading
delay(10);
Serial.print(test1, DEC);
Serial.print(0, BYTE);
delay (50);
}

I used the A and B prefix and it seems to be recieved well in the flash trace output, the flash code is:

FLASH CODE:
createSocket ();

function createSocket () {

serialServer = new XMLSocket ();
trace ("made it" + serialServer);
//127.0.0.1 is the same as "localhost" ie an alias to your local machine
//it is concievable to that you would want to connect from another machine and you would change this
serialServer.connect ("127.0.0.1", 5331);
serialServer.onConnect = function (success) {
};

serialServer.onClose = function () {
trace ("closed");
};

serialServer.onData = function (data) {
trace ("incoming" + data);
test = data;
test2=data;
_root.text1.text = ("light Sensor = " + test);
_root.text2.text = ("potentiometer = " + test2);
};

}

The trace output is
incomingA0
incomingB420
incomingA0
incomingB432
incomingA0
incomingB420
incomingA0
incomingB425
incomingA0
incomingB425
incomingA0
incomingB419
incomingA0
incomingB432
incomingA0
incomingB421
incomingA0

I'm trying to get the inputs into two seperate dynamic text boxes at the moment and am not having much luck as it just reads the same in both boxes obviously. Anyone know or can offer advice on how to read the numbers out of the input into the dynamic text boxes?

I think it is a code issue but I have no idea how to write the code in flash properly, any advice or help on this is apprectiated.

First off there is no need to to put the delay(10) between the print A and the variable number.

Second I have never programmed in flash in my life so I can only tell you the sort of thing you have to do not what to do.

You need to look at the incoming data string and test the first character to see if it is an A or a B. Then depending on the result put the following date in the appropriate text box having first striped off the A or B.
In most languages this involves some sort of IF statement.