i am afraid that i can't understand what you mean by serial command hanling!
did you mean that i have to enter it in serial monitor? or in sketch?
You would have to enter the command in the serial monitor, then press [ENTER] or [RETURN] on the PC keyboard or click the "Send" button. But it will only work if you have a sketch which can handle that as serial input.
Is this code
all I need to enter?
At first you will need a sketch for serial command and time handling that
- reads the command from the serial monitor
- split an convert the numbers to year, month, date, hour, minute, second
- and must provide a processing logic using the millis() function to regularly update the time
No extra hardware required, but you'd have to enter the time manually after each reset of the controller.
Another possibility would exist with compiling and uploading a sketch. When compiling, you could create a "time stamp of compile date/time" in your sketch. Each time the sketch starts, it then could read that time stamp from the hex file uploadet to the Arduino. So if you do this:
- compile and upload the sketch
- immediately start the serial monitor
You could have the current date and time in your sketch without manually entering ist. Just 5 seconds late or so from your PC clock, which would be the estimated time for compiling, uploading and starting the serial monitor. Unfortunately: After each reset of the controller, the time will alwas start at the date/time when the sketch was compiled.
So you can decide what you would like to have, then I can create one example sketch for you. Two possibilities:
Create a clock that starts with zero or any given starting date/time. You then can "set" the date and time via the serial monitor to any date/time you want.
Create a clock that always starts at the date/time when the sketch was compiled and uploaded to the Arduino. But each reset of the controller resets date/time. So to have a current time you would always need to upload a new sketch.
If you select one of the possibilities, I can program an example program for you. Just let me know what you want and also tell me about your preferred date formatting, whether it is "dd.mm.yyyy hh:mm:ss" like in Germany or any other date/time formatting you would like to have.