Setting up LED's to only run at night for 3 hours and then repeat the next day
Bob2bot
Posts: 13
in BASIC Stamp
I made a program to run 3 LED's when it got dark using a photo resistor and the RCTIME function which worked fine. I now want it to only run for 3 hours after dark and then reset itself to run the next day. I have tried using a counter variable together with a DO UNTIL the counter equals a set value but am stuck how to make it reset for the next day. Is there a way to bring in some type of clock function or other way to limit the run time.
Comments
If you label your main code with a line like this:
Then when your code hits the goto line it will jump back up to the beginning of your code. I am not 100% on my syntax because I have not written PBASIC in forever, but this should get you started in the right direction.
If I understand your post, you are able to detect when it gets dark, turn on the LEDs for three hours and then turn them off. And what you want to do is leave them off until the following dusk.
You could use a loop containing a PAUSE that gets you past dawn and then start over again searching for dusk.
The SLEEP command can be your friend for the long stretch to the next day. The SLEEP command on the Stamp is fairly accurate, because it is calibrated against the resonator.
I don't know what your 3 display LEDs need to do during the 3 hours after dark, but let's suppose that they need to be updated once a second. A loop that runs once per second 10800 times will eat up three hours. The PAUSE command can help with that.
Thanks to all, the Pause and Sleep commands worked perfectly. - Bob