Need Help Distinguishing Values

Hello,

I am building a robot arm for Science Olympiad which is in a week. The whole concept of the robot is that it is technically motioned controlled. The robot will be controlled by a scale model made of poly sheet with potentiometers in the same places that the servos would be. I am trying to make a program in processing that monitors and displays the positions of the pots on a computer. But, when the Adruino prints the values, the program can't tell which value belongs to which pot. Can someone tell me how to send multiple values, and processing knows what each value belongs to?

  // "Pot" = Potentiometer

#include <Servo.h>
#include <SoftwareSerial.h>


Servo servo1;   // Base rotation
Servo servo2;   // Close to base
Servo servo3;   // Middle
Servo servo4;   // End
Servo servo5;   // X-Axis of claw
Servo servo6;   // 360° rotaion of claw
Servo servo7;   // Open and close of claw
Servo servo8;   // Open and close of claw

int pot1 = A0;  // Pot base rotation on analog pin 0
int val1;  // varible assigned to analog pin 1
int pot2 = A1;
int val2;
int pot3 = A2;
int val3;
int pot4 = A3;
int val4;
int pot5 = A4;
int val5;


void setup()
{
  servo1.attach(3);  // Servo 1 in connected on pin 0
  servo2.attach(4);
  servo3.attach(5);
  servo4.attach(6);
  servo5.attach(7);
  servo6.attach(8);
  servo7.attach(9);
  servo8.attach(10);
  Serial.begin(9600);
}

void loop()
{
  val1 = analogRead(pot1);
  val2 = analogRead(pot2);
  val3 = analogRead(pot3);
  val4 = analogRead(pot4);
  val5 = analogRead(pot5);
  val1 = map(val1, 0, 1023, 0, 179);
  val2 = map(val2, 0, 1023, 0, 179);
  val3 = map(val3, 0, 1023, 0, 179);
  val4 = map(val4, 0, 1023, 0, 179);
  val5 = map(val5, 0, 1023, 0, 179);
  servo1.write(val1);
  servo2.write(val2);
  servo3.write(val3);
  servo4.write(val4);
  servo5.write(val5);
  delay(15);
  Serial.println(val1);
  Serial.println(val2);
  Serial.println(val3);
  Serial.println(val4);
  Serial.println(val5);
}

Before you go much further, find out about arrays.

the program can't tell which value belongs to which pot.

So, label them.

 Serial.print("value 1 is ");
 Serial.println(val1);
 Serial.print("value 2 is ");
  Serial.println(val2);
 Serial.print("value 3 is ");
  Serial.println(val3);
 Serial.print("value 4 is ");
  Serial.println(val4);
 Serial.print("value 5 is ");
  Serial.println(val5);

JBatista:
Can someone tell me how to send multiple values, and processing knows what each value belongs to?

I suggest using a CSV format. Design your sketch to print out a fixed set of values in a fixed order on a single line, and separate the values by commas. In Processing, separate each line at the commas to obtain the ascii representation of each value, and then parse that to give you the corresponding number. The order of the values would be hard-coded into the Arduino when sending the values, and hard-coded in the Processing code for receiving them.

The order of the values would be hard-coded into the Arduino when sending the values, and hard-coded in the Processing code for receiving them.

The problem I see with this approach is that you may send many values that rarely or never change.

Sending data Grumpy Mike's way means that you can elect not to send stuff that hasn't changed since last time you sent.

That's true, but in the context of this problem where the OP wants to send the positions of a set of pots, I think that sending the state of all pots as a set is a reasonable solution.

some servo/pot test code that has some deadband to limit printing to the serial monitor unless there is noticable change in pot output. Prevents a data spew to the serial monitor.

//zoomkat dual pot/servo test 12-29-12

#include <Servo.h> 
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //my pot pin
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup() 
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop() 
{ 
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179); 
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print("2- ");    
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50);
}

I like Grumpy_Mike's idea of just putting a line before the values are printed indicating which one is which. Two things though. How do I tell the Arduino to stop spamming my serial monitor, and only update the values when they are changed? Also, how do I tell processing to look at a specific value after the line that indicates which value it is, is printed. Example; processing would retrieve the values of pot1 after "Potentiometer 1 = " is printed.

How do I tell the Arduino to stop spamming my serial monitor, and only update the values when they are changed?

by remembering the last reading for each input, and only sending the value if the latest reading and the previous reading differ.

That method was designed for humans to read. Processing can still read it but it would be simpler if you followed the value with an identifier byte.
For example tag A, B, C and so on onto the end of a value so you get 214A for pot one.
Then at the processing just isolate the last character in the string to see what it is and use the string to number function to recover the value.