I am trying to run the following code
unsigned long myTime;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Time: ");
myTime = millis();
Serial.println(myTime); // prints time since program started
delay(1000); // wait a second so as not to send massive amounts of data
}
But my in the serial terminal I only get the following output
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 0
Time: 1
Time: 0
Time: 1
Time: 0
Time: 0
Time: 0
Time: 0
Time: 1
Your topic was MOVED to its current forum category which is more appropriate than the original as it is certainly not an Introductory Tutorial
I know that the simulator works fine, but what could be the reason that I get the wrong output? I am using an Arduino Mega ADK.
I get
Time: 0
Time: 999
Time: 1999
Time: 3000
Time: 4000
Time: 5000
Time: 6000
Time: 7001
Time: 8001
Time: 9001
Time: 10001
Time: 11001
Time: 12002
Time: 13002
Time: 14003
Time: 15003
Time: 16004
Time: 17003
...
your upload probably failed, you are running a previous sketch
I guess you have not installed/connected it properly, I'm not a clairvoyant
system
Closed
June 13, 2023, 12:52pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.