serial printing trouble

hello,

I am not sure how to have 4 variables print at the same time. For example I have 4 timers, and I would like them to print next to each other. It would look like this(in my mind)

timer1, timer2, timer3, timer4 timer1, timer2, timer3, timer4 timer1, timer2, timer3, timer4 timer1, timer2, timer3, timer4

and so on. can anyone help me print them like this?

Thanks student238

serial.print(timer1value); serial.print(","); serial.print(timer2value); serial.print(","); serial.print(timer3value); serial.print(","); serial.print(timer4value); serial.println("");

serial.print(timer1value);
serial.print(",");
serial.print(timer2value);
serial.print(",");
serial.print(timer3value);
serial.print(",");
serial.print(timer4value);
serial.println("");

I tried these commands and I can’t read the values that its printing. The feed back that I am getting is displaying across the debug screen. I tried to use the “Serial.println” function and I can’t read that either. I can do serial.println (timer1value) and I can read that perfectly, but this displays only one of the values and not all 4 of the timers.

 Serial.print(timer1value); 
Serial.print(", ");
Serial.print(timer2value); 
Serial.print(", ");
Serial.print(timer3value); 
Serial.print(", ");
Serial.println(timer4value);

You may be better off with an array, but the capitals are more important.

Post your code.

Osgeld: serial.println("");

size_t Print::println(const char c[])
{
  size_t n = print(c);
  n += println();
  return n;
}

size_t Print::print(const char str[])
{
  return write(str);
}

size_t write(const char *str) {
  if (str == NULL) return 0;
  return write((const uint8_t *)str, strlen(str));
}

size_t Print::println(void)
{
  size_t n = print('\r');
  n += print('\n');
  return n;
}

println("") calls three useless functions before calling println(). Why not just call println() directly?

println("") calls three useless functions before calling println().

In that context, they are useless. Used properly, they are hardly useless.

I want to get all of my timers to display their values on the print screen, If i just use the println directly then I can only display one of the variables. I don't not believe that I can print all of them with that one function. and if I use just the print function then when the program prints, the program prints across the screen and not down the screen.

What was wrong with AWOL's code? That is how I would have suggested doing it.

student238:
I use just the print function then when the program prints, the program prints across the screen and not down the screen.

You do understand that there is Serial.print() and Serial.println()? Serial.println() will advance to the next line after printing. Surely you can see how to modify the code already given to make the variables print “down” and not “across.”

You can using Streaming.php library for easy printing just like you want: http://arduiniana.org/libraries/streaming/

You can using Streaming.php library

.php? PHP doesn't run on an Arduino.

Of course, that doesn't really matter as the downloadable zip file contains Streaming.h, not Streaming.php.

Oops. Sorry I meant to say Streaming.h :)