Hi everyone,
I have a quick question about how I should write the order for a series of serial print functions in order for it to show up on the serial monitor the way I would like it.
I have 4 distances sensors labelled 8, 9, A, B that each reads specific distances. I also have a real time clock that prints out the date and time when the distances are read. I would like the data to show up like this on the serial monitor:
Date, Time, Sensor[8], Sensor[9], Sensor[A], Sensor
2018/6/20, 11:48:7, 129, 30, 57, 30
Date, Time, Sensor[8], Sensor[9], Sensor[A], Sensor
2018/6/20, 11:48:7, 145, 120, 22, 0
I've attached what the serial monitor looks like now as well as the code for that section.
```
**void loop()
{
address = address_min;
while (address <= address_max) {
perform_single_range(); //V53L0x takes measurement
delay(210); //allow for high accuracy mode
get_result(); //get measurement result from V53L0x
Serial.print("Date, ");
Serial.print("Time, ");
Serial.print("Sensor");
Serial.print("[");
Serial.print(address, HEX);
Serial.print("]");
Serial.print(" ");
Serial.print(distance, DEC);
Serial.print("\t");
address++;
}
Serial.println(""); //print newline
DateTime now;
// delay for the amount of time we want between readings
delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
digitalWrite(greenLEDpin, HIGH);
// log milliseconds since starting
uint32_t m = millis();
// fetch the time
now = rtc.now();
//print date to serial monitor
#if ECHO_TO_SERIAL
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(", ");
#endif //ECHO_TO_SERIAL
//print time to serial monitor
#if ECHO_TO_SERIAL
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
Serial.print(", ");
#endif //ECHO_TO_SERIAL
}
__```__
__