0

I want to program for a timer that works as set timer such as in an oven where user can set their own time. One of the way I know is using an IC(RTC) for the timer. However, I don't have the IC yet only the coding and Arduino.

Is it possible to simulate the Arduino code without having the RTC? Or is there any electrical component that I can use to replace the IC for the time being? Thank you for your help and comment.I really appreciate that.

closed as off-topic by per1234, VE7JRO, sempaiscuba, MatsK, Delta_G May 30 '18 at 0:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – per1234, VE7JRO, sempaiscuba, MatsK, Delta_G
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    You can, by using millis(), if you can tolerate the mediocre frequency accuracy of the ceramic resonator clocking the Arduino. – Edgar Bonet May 15 '18 at 10:46
  • 2
    Yes, if you don't mind if your cake cooks for 1 hour or 1 hour and 5 seconds. :) – Nick Gammon May 15 '18 at 11:16
  • Are you referring to a RTC (Real Time Clock) chip? – Majenko May 15 '18 at 12:00
  • 1
    Reply to Majenko: Yes the RTC chip. – StudentBeginner May 15 '18 at 12:02
2

TimeLib.h has a virtual clock that can be updated and corrected from multiple sources, including an RTC chip or an NTP server on the internet (assuming an internet connection).

It doesn't need that clock source, though, but it will drift with time. Once you have set the clock correctly it will keep close to the right time (assuming no reset or power loss of the Arduino). Not perfect (because the Arduino's main clock isn't perfect) but close enough for many simple applications.

0

There are programs to simulate Arduino code, but they are very limited. To really simulate the circuit the program would have to also know about the IC you are using. You didn't told us what IC this is, so we can only speculate, that it might not be something, that these programs know (though you can try it). And sometimes Arduino Simulators have problems with simulating time sensitive code. If you want to try, just google for Arduino Simulator and check out the possibilities. I cannot suggest one, since I didn't use one until now.

At this point it might be the better option to write time-keeping code using the millis() function, which returns the number of milliseconds since the Arduino started. Save a timestamp from when you started and compare the difference between millis() and your timestamp to the wanted bake time.

You can pack this code in extra functions, that can later be replaced by code managing the "timer IC". With dividing your code this way you can write the rest of the logic without bothering about the timing part (after writing the millis() part as a "dummy").

For an oven timer the accuracy of the Arduinos clock should be ok, since it doesn't really matter, if it is a few seconds off. And for testing and writing the first code version it is also sufficient.


If the IC you are referring to is a RTC (Real Time Clock) module, the code for it should be pretty simple to write. There are libraries for the most common RTCs. You might want to try the Arduino Time library.

Not the answer you're looking for? Browse other questions tagged or ask your own question.