• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Does anybody know a list of clock commands?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does any of you know a list of clock functions of something? I have this Language Reference for arduino: arduino.cc/reference/en But there's nothing about time & date, so if any of you know where i can find such functions and commands it would be really nice.

My goal is to make a very simple arduino code, so a LED strip will turn on when the clock is for example 23:25 and turn off again at 04:14 and so the code will repeat that every time the clock becomes e.g. 23:25 again.
I also want to be able to make the LED light fade slowly in and out. (so it takes e.g. 5 min to fade into full brightness, and out again when it's suppose to turn off)
I am not a very good programmor so i really hope you guys can help me out, especially because i can't find any code with a time stamp that i can edit INSIDE the code.

If you write any code, can you then please make a comment next to the code that explains what every line of code does? That helps me understand how it works.

Thanks



 
Rancher
Posts: 259
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - googling "c time functions" took me here:
https://www.tutorialspoint.com/c_standard_library/time_h.htm
which is quite a handy summary, and is this the sort of thing you could use? (If you want the time as a string eg. "HH:MM:SS" rather than hours/minutes/seconds values then you probably want to use the strftime() function.)
Output:


 
John Matthews
Rancher
Posts: 259
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...although doing a bit of research, I don't think any of those functions are available on an arduino? If that's the case then apologies; you'll need something arduino-specific.
 
John Matthews
Rancher
Posts: 259
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at this:
https://www.electronicwings.com/arduino/basic-functions-related-to-time-and-interrupts-in-arduino
implies there isn't anything that will give you the current time, only time since the program started.

Do you have some way of inputting an absolute time value which your code could add the millis() value to to get the current time?
 
Meladi Catalino
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Matthews wrote:Looking at this:
https://www.electronicwings.com/arduino/basic-functions-related-to-time-and-interrupts-in-arduino
implies there isn't anything that will give you the current time, only time since the program started.

Do you have some way of inputting an absolute time value which your code could add the millis() value to to get the current time?



-Oh, does that mean that everytime you start the Arduino you have to physically change a number/time that the mills() function adds itself to?
I'll just use a DS1307 or a DS3231... So it keep track of the time every day for me... instead of typing a new number/time in every time i start the arduino
 
John Matthews
Rancher
Posts: 259
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Meladi Catalino wrote:does that mean that everytime you start the Arduino you have to physically change a number/time that the mills() function adds itself to?

I know next to nothing about the adruino, but that's what it looks like just based on that article.

I'll just use a DS1307 or a DS3231... So it keep track of the time every day for me... instead of typing a new number/time in every time i start the arduino

Sounds like a good plan
 
John Matthews
Rancher
Posts: 259
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Matthews wrote:I know next to nothing about the adruino

Can't even spell it
 
Marshal
Posts: 3263
487
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Meladi Catalino wrote:[Oh, does that mean that everytime you start the Arduino you have to physically change a number/time that the mills() function adds itself to?
I'll just use a DS1307 or a DS3231... So it keep track of the time every day for me... instead of typing a new number/time in every time i start the arduino


Either use a hardware RTC like the DS3231 that you mentioned, or if you have WiFi or some other connectivity, grab the time from a network resource.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic