0

a digital led ring clock help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

a digital led ring clock help

by oflander on Thu Jan 11, 2018 6:15 pm

I haven't done electronics or programming in over 30 year, but I want to build a special LED clock. I have neopixel 60-1/4 rings and led matricies and arduino uno and mega2560s. My plan was to have a seconds ring, a minute and hour ring, 12 hour off ring markers, 3 simulated pendalums, a 8x24 traveling message marquee, and a hour glass display. Every 15 minute it would give a 5-10 second light show. the rings are 120 leds, the pendalums are 24 leds,the hourglass is 60 leds and the marque is 128 leds, plus 12 hour markers.
My problem is this, I can't get my head around the code. I've gone thru 3 notebooks, I've tried 'for loops','If' statments, 'subroutines'. -ETC. I cant seem to get from -sec to min, back to secs, back to min and then to hours and back to secs-, and to figure in my 15 minute show. I'm 70 and never backed down from a challenge, I've been all over the web. I've got rtcs, 74hc595's, a 5v-5a power supply plus more. Can someone help with some arduino code to get me over the hump. I think I have forgotten more than I ever learned.

oflander
 
Posts: 5
Joined: Thu Jan 11, 2018 6:12 pm

Re: a digital led ring clock help

by kcl1s on Fri Jan 12, 2018 12:34 am

Well your project has a lot going on. When you want to do multitasking like that the code gets more complex. You can no longer use delay() in your code because you have other things to do while waiting. Adafruit has a good set of guides on multitasking with Arduino https://learn.adafruit.com/search?q=multitasking&

My advice is to break the code down into smaller chunks and see if you can get that part working then move on to the next. If you have trouble with the code you come up with, post it here between code tags using the button above the forum edit window. We can help with code questions but you have to give us something to start with.

A fellow hobbyist
Keith

kcl1s
 
Posts: 816
Joined: Tue Aug 30, 2016 12:06 pm

Re: a digital led ring clock help

by oflander on Thu Mar 01, 2018 9:30 pm

I think I have found a partial solution. I will attempt to run multiple items by starting with a time base for part of my clock, then setting a counter. Using the counter to set off another part of my clock and also setting another counter to set off another item,and so forth. Each part of the project would rely on the count that was conditioned from another counter. For example, I have a spinner that changes every 100 ms, so my counter adds 1 every 100 ms, when this counter get to 5, it will change my pendalum to the next position, and it sets it's own counter for another item. Once a counter has made the change and I won't need it for a given time, it will be reset to zero. Each item will be placed in a function with global counters. I think this will work better than "millis" swapping, because my longest period is 40.5 hours for my moon phase. That's a lot of millis! Thanks for everyone's help. I will get there someday- when I get it built I will post pictures!

oflander
 
Posts: 5
Joined: Thu Jan 11, 2018 6:12 pm

Re: a digital led ring clock help

by adafruit_support_bill on Fri Mar 02, 2018 6:49 am

Cascaded counters is certainly a reasonable approach - especially with the number of different display functions you have going on.
But 40.5 hours is well within the range of millis timing. The millis clock on an Arduino is a 32 bit counter and takes about 49 days to roll over.

adafruit_support_bill
 
Posts: 68515
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.