I’m fairly new to Arduino programming and I’m wanting to create a program to output data from a temperature sensor as well as time through the Arduino serial monitor. I can get the temperature to output without any problems, but I’m having trouble figuring out how to program a timer and have them both display side by side on the serial monitor. Any advice would be greatly appreciated.
There is a function in Arduino that reports the count of miliseconds since powerup (or since the last counter roll-over every 49-ish days):
http://arduino.cc/en/reference/millis
You can use the code on that page to get you started. But you probably want to use it to develop a clock/date counter to reduce the miliseconds to a proper time/date format. Store the latest value of it, and update the seconds whenever the current value is a second later than the stored value. If minute/hours/days/month counter overflows update those too. Don’t update and continue the loop to do other stuff if the next second hasn’t passed fully.