Short form of the Serial.print.....

Currently connected the MPU6050 and have to type all the serial.print statements for each line.
Is there a easier way or shorter way to type all values and strings in?

Serial.print("aX = ")
Serial.print(ax);
Serial.print("\t");
Serial.print("aY = ")
Serial.print(ay);
Serial.print("\t");
Serial.print("aZ = ")
Serial.print(az);
Serial.println("\t");
Serial.print("gX = ");
Serial.print(gx);
Serial.print("\t");
Serial.print("gY = ")
Serial.print(gy);
Serial.print("\t");
Serial.print("gZ = ");
Serial.println(gz);
Serial.println("");

sprintf to a temp char[].

shorter way

Serial.print("\t");
Serial.print("aY = ")

You can combine that into one print.

You could use snprintf, but it is debatable whether it would be easier. It would be 3 lines though.

You could use "cout"-style (like C/C++ output streams on the desktop).

Code:

---



```
const char* endl = "\r\n";

template <class T> inline Print &operator<<(Print &printer, const T printable)
{
  printer.printcolor=#000000[/color];
  if (printable == endl)
    printer.flushcolor=#000000[/color];
  return printer;
}

void setupcolor=#000000[/color] {
  Serial.begincolor=#000000[/color];
  size_t countTo = 10;
  Serial << "Let's count to " << countTo << '!' << endl;
  for (size_t i = 1; i <= countTo; i++) {
    Serial << '\t' << i << endl;
  }
  Serial << endl
        << "Now, let's find their doubles!" << endl;
  for (size_t i = 1; i <= countTo; i++) {
    Serial << '\t' << i << " * 2 = " << (i * 2) << endl;
  }
}

void loopcolor=#000000[/color] {}
```

|

Output:

---



```
Let's count to 10!
1
2
3
4
5
6
7
8
9
10

Now, let's find their doubles!
1 * 2 = 2
2 * 2 = 4
3 * 2 = 6
4 * 2 = 8
5 * 2 = 10
6 * 2 = 12
7 * 2 = 14
8 * 2 = 16
9 * 2 = 18
10 * 2 = 20
```

|

Or make a simple function:

void sendCommand(const char[] name, [some type] value){
  Serial.print(name);
  Serial.print(" = ")
  Serial.print(value);
  Serial.print("\t");
}

Which simplifies it to:

sendCommand("aX", ax);
sendCommand("aY", aY);
sendCommand("aZ", aZ);
sendCommand("gX", gx);
sendCommand("gY", gY);
sendCommand("gZ", gZ);

have to type all the serial.print statements for each line.

I presume that you already use copy/paste then revise the entries rather than typing the whole lines each time.