Hello all,
I have a ridiculously simple task I need some help with... I've built a robotic cat laser toy and I want it to turn on at a specified time of day, run for a few minutes, then turn off, and have that repeat daily.
I have an Elegoo Uno r3 (with shield) attached to a turret with a couple of servos, a laser, and a DS-3231 RTC module. From testing, they all seem to be connected properly.
I've already got the code sorted for when it's on (moving the laser about somewhat randomly with short intervals), what I need is code to set/keep time and start and stop the movement every day.
Please let me know what else you need to know about my setup. I know it's not a complex thing I'm looking for, but I've tried to teach myself and I just don't have the patience or maybe the aptitude to learn this whole new language when, at this point, all I really want to do with it is build this toy
Thanks very much for your time.
-Yahenda
I'd figure a small adaptation to the examples that come with the various DS3231 libraries should do the job.
Hi Yahenda,
Here's a thought. Why not simply plug the system into a timer? You could modify the sketch to only run for a short amount of time then stop. The next day the timer will restart the system... every day.
Plus the system won't need to be powered all of the time.
Pat.
wvmarle:
I'd figure a small adaptation to the examples that come with the various DS3231 libraries should do the job.
Hi wvmarle, thanks for the reply... I've tried with DS3231 libraries' examples but I can't get the unit to learn and keep time... I know what you call a small adaptation seems simple to you, but as I said, it's a whole other language to me. If it's really that simple, please, by all means tell me exactly what to do and I will try!
Thx
patduino:
Hi Yahenda,
Here's a thought. Why not simply plug the system into a timer? You could modify the sketch to only run for a short amount of time then stop. The next day the timer will restart the system... every day.
Plus the system won't need to be powered all of the time.
Pat.
Hi patduino... Thanks for the idea... what kind of timer are you talking about? Is it something that might be included in some of the starter kits one can by? I've got the 'UNO R3 Project Super Starter Kit' and a Elegoo v2.0 - 37 sensor kit. Any specifics would help.
Thanks
wvmarle,
Yes, exactly like that. Just a simple timer that automatically turns a lamp on / off in the evening.
Yahenda,
The actual code to turn things on and off at specific times using the RTC library is pretty simple. I have a series of Arduino programs that does something very similar: changes the selling price of an item based on the time of day.
In my experience, the harder part is setting the time of day (setting the clock) and setting your feeder on/off times. You can do it with various types of user interfaces: from the serial connection, with a touchscreen, or with an LED and a couple of pushbuttons.
It's trivial to hardcode these things, but changing them tends to require a fair amount of code because anything that is going to be adjusted by an actual person requires a lot of error-handling work. That's where most of the work (and cost) comes in.
If you'd like me to modify the code I have for your use, send me a PM. However, I think you'll find it's simpler and costs less to just use an off the shelf timer like patduino suggested. Blatant self-promotion, but I also sell these timers
I would rather put a start button and let the cat push it whenever it likes.
patduino:
wvmarle,
Yes, exactly like that. Just a simple timer that automatically turns a lamp on / off in the evening.
patduino and wvmarle - Thanks for your suggestions, I believe you're right, that's the most straightforward solution... and just now, as your suggestion got me thinking outside of the 'project kit' box... I realized I've got some wifi sockets for my lamps controlled by my Google Home mini! I could create a routine that turns the laser on and off daily, automatically... and I've already got the stuff I need right here, right now! XD
The BEST feeling. Thank you!
cedarlakeinstruments:
It's trivial to hardcode these things, but changing them tends to require a fair amount of code because anything that is going to be adjusted by an actual person requires a lot of error-handling work. That's where most of the work (and cost) comes in.
cedarlakeinstruments - I think you get what I'm saying exactly... Although it would be fascinating to deep dive into all the possibilities, realistically it's a larger investment than I'm prepared to make right now, for this. Thanks for the coding offer and don't worry about self-promo, we all could use some - when we're all a little shameless, there's no shame
blimpyway:
I would rather put a start button and let the cat push it whenever it likes.
blimpyway - I like that idea very much! I will look into that, too
I have solution for that via external webserver for Arduino with Ethernet shield. If some interested, PM.
martinius96:
I have solution for that via external webserver for Arduino with Ethernet shield. If some interested, PM.
Maybe it's just me, but this seems like so much overkill for a basic timer.