I will using aTTINY85 chip. Where can I find the code for delay timer for every 24 hours. I would said set up time from 7 pm to 12 am to turn on and rest the day is turn off. anybody know where can I find the code? please help thank you very much
Have you looked at the examples? Timing is one of the first things....
Why are you looking to find code rather than write it?
It is quite simple, just look at the blink without delay example in the IDE.
how many 1000 milliseconds for every an hour?
The millis timer is good for about 56 days delay it works on an unsigned long variable.
But 60 * 60 * 1000
ironheartbj18:
how many 1000 milliseconds for every an hour?
Seriously?
perfect thanks i am working on it
86,400,000 (24×60×60×10×10×10) milliseconds — one day
divide by 24 hours is 3,600,000 per hour. thx!
86,400,000 (24×60×60×10×10×10) milliseconds — one day
divide by 24 hours is 3,600,000 per hour.
per hour * 6 = 21,600,000
Can i put 21,600,000 Millis in the code blink without delay then delay (64,800,000(86,400,000-21,600,000))
Does i have to put unsigned long?
unsigned 6 hours long = 21,600,000
unsigned 18 hours long = 64,800,000
if LDR sensor see the dark automatically starts on for 6 hours. Should i don't worry about the 18 hours?
if (analogRead(sensor)
HIGH TO
redtoyellow();
yellowtogreen();
greentocyan();
cyantoblue();
bluetomagenta();
magentatored();
unsigned long (6 hours) 21,600,000
sensor_crystal_glass_cross.ino (2.73 KB)
You can't have spaces in your variable names if that's what that is.
If you need to read a sensor or do anything else during the delay then you can't use the delay function, you have to use the BlinkWithoutDelay code structure. This explains why...
You have to use unsigned longs for variables used for timing with millis(), but as they can hold a value up to 4,294,967,295 then timing for 24 or less hours using this method is no problem but it will not be as accurate as using an RTC