Serial in degrees

Ok, i almost have it, i am just a little hung up. I have two servos and want to show the arm position in degrees. I got it working but the serial monitor shows both servo1 and servo2 position consecutively. in other words, as i move servo1 and the serial monitor shows where the arm is... servo2 degrees is displayed in tandem with servo1. Not what i intend. I want to show individually what the position of where the servos are in relation to degrees. I am sure it is an easy fix. i do not play with serial often. here is the code:

void loop(){
  val1 = analogRead(potPin1);//reads the value of the pot(0 to 1023)
  val2 = analogRead(potPin2);
  val1 = map(val1, 0, 1023, 0, 180);
  val2 = map(val2, 0, 1023, 0, 180); //scales it down to 0 to 180
  arm1servo.write(val1); //sets servo position according to scale
  arm2servo.write(val2);
  delay(15);//servos time to get there before next input
  Serial.print("Servo1 degree ");
  Serial.print("Servo2 degree ");
  Serial.println(val1);
  Serial.print(val2);
}

It might look better to put the value on the same line as the label:

 Serial.print("Servo1 degree ");
  Serial.println(val1);
  Serial.print("Servo2 degree ");
  Serial.println(val2);

Sorry for not getting back soon John. I did what you said, and added a Serial.print("\n");

This seemed to seperate the lines well, however, the lines scroll super fast where you cant read the numbers.

Here's what i did next and it was interesting: I added a delay at the end of the serial codes and the servo moves to the speed of the delay I set. Ever heard of that? in my current code, there is already a delay of delay(15); for the servos. So my question is, how do i get the serial monitor to slow down without slowing down the servos?

the new code:

void loop(){
  val1 = analogRead(potPin1);//reads the value of the pot(0 to 1023)
  val2 = analogRead(potPin2);
  val1 = map(val1, 0, 1023, 0, 180);
  val2 = map(val2, 0, 1023, 0, 180); //scales it down to 0 to 180
  arm1servo.write(val1); //sets servo position according to scale
  arm2servo.write(val2);
  delay(15);//servos time to get there before next input
  
  Serial.println("Servo2 degree: ");
  Serial.print(val2);
  Serial.print("\n");
  Serial.println("Servo1 degree: ");
  Serial.print(val1);
  Serial.print("\n");

  
}

You can display the serial data less frequently. One way is to keep a variable per servo that stores the previous angle it was set to. Only print the serial info if the angle has changed by say five or more degrees. Or count how many times you've been round loop; at 500 times (or whatever), print the data and reset the count. Or use the blink without delay technique and just print once a second.

Wild bill thank you. Do you happen to have an example? Perhaps know where I can reference it?

unsigned long LastPrintTime;
void loop()
{
  val1 = analogRead(potPin1);//reads the value of the pot(0 to 1023)
  val2 = analogRead(potPin2);
  val1 = map(val1, 0, 1023, 0, 180);
  val2 = map(val2, 0, 1023, 0, 180); //scales it down to 0 to 180
  arm1servo.write(val1); //sets servo position according to scale
  arm2servo.write(val2);
  delay(15);//servos time to get there before next input
  
if(millis()-LastPrintTime > 1000)
  {
  Serial.println("Servo2 degree: ");
  Serial.print(val2);
  Serial.print("\n");
  Serial.println("Servo1 degree: ");
  Serial.print(val1);
  Serial.print("\n");
  LastPrintTime=millis();
  }
}

Good stuff Wildbill. Worked like a charm. Thank you very much!

Some servo/pot test code I’ve used in the past.

//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

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

int potpin1 = 0;  //analog input pin A0
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);
}

Thank you zoom!