When I use the millis() function to incorporate a time component to my sketch, I get these random characters that show up on the first line of the serial monitor when I initially start up the serial monitor. Why does this happen? And is there a way to fix this?
unsigned long time;
const int ldrSensor = A1;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Time: ");
time = millis();
Serial.print(time);
Serial.print("ms");
Serial.print(" ");
delay(50);
int ldrRead = analogRead(ldrSensor);
Serial.print("LDR = ");
Serial.print(ldrRead);
Serial.println(" ");
delay(50);
}
Here is what I see when I start up the serial monitor. The first line shows the random characters.
LDRꢪþTime: 0ms LDR = 406
Time: 100ms LDR = 405
Time: 200ms LDR = 405
Time: 302ms LDR = 405
Time: 402ms LDR = 404
Time: 502ms LDR = 404
Time: 604ms LDR = 405
Time: 704ms LDR = 407