Using millis to determine weekdays

Hello everyone!

The past couple of days iv'e been struggeling to code a time and date system in arduino, without external libraries... Does anyone know how to code it? :)

Here is a snippet of my code :)

//time variables long sek = 1000; //seconds long minu = 60000; //minutes long tim = 3600000; // hours long dag = 86400000; // days long nutid = 0; // timeNow

void loop(){

long nutid = millis(); // the time now long offSetTid = (nutid + 604800000); // so i adjust the time long dage = (offSetTid / dag); // days long timer = ((offSetTid % dag)/tim); // hours long minutter = (((offSetTid % dag)%tim)/minu); // minutes long sekunder ((((offSetTid % dag) %tim)%minu)/sek); // seconds1

Here' a snippet of my answer - "What's the probl"

The Arduino does NOT know what time it is, without external hardware. It ONLY knows how long, roughly, it has been since it was reset.

  long nutid = millis(); // the time now

No, that is NOT the time now.

Consider adding a real time clock module:

You most certainly can make your arduino into a clock, and in fact, there is a Library (included in the IDE) called Time.h to help you with that.

Look in the IDE examples for the Time library. You can learn all about how to manage Time functions on your arduino.

As pointed out, it doesn't make for a great clock... so you may want to spend a few dollars on a RTC like this one and make it into a fine clock.

thecatmiaw: Hello everyone!

The past couple of days iv'e been struggeling to code a time and date system in arduino, without external libraries... Does anyone know how to code it? :)

http://forum.arduino.cc/index.php?topic=408565.0