LED Clock ring with ADA fruit neo pixels

Hi folks.

One of my projects is coming on again now as I have time to program it.

I have a 60 LED neo pixel ring of LEDs and that is the perfect size for a clock.

I was pulling my hair out with how to do this and all the problems of memory, arrays and the like.

A while back I had a Eurika moment and got it working. Though it still has problems.

My original way of doing it was to make a lot of arrays and OR them together. This wasn’t practical as there isn’t that much memory in the Arduino and other reasons.

This is the code so far, but it still has a couple of problems.

1 - the second had, as it passes 12, turns white from blue and I am not sure why.
2 - I wanted the 3, 6, 9 and 12 positions to be shown. They aren’t.
3 - it is “problematic” in that I am fixed to using that particular library. I was wanting to make it more generic so other RTC chips could be used and other libraries. Alas trying a different library caused problems with compiling.

This is a badly written code in that it is “flat” and doesn’t really have many functions/routines.
Most of the variables are GLOBAL and it is still a bit messy.

One thing which threw me for a while was the MOD(60) which was needed to keep the LEDs in a valid range.
I think that is part of the problem with the second hand turning white when it passes the 12 o’clock position.

I would appreciate a bit of help with the code if you could please afford me the time.

I am also wanting to include alarms so at a certain time, the alarm “displays” by maybe turning the ring RED/“you pick the colour” sort of thing.

Thanks again.

LED_Clock11.zip (2.54 KB)

  if (hr < 13)

As opposed to the more sensible

  if(hr <= 12)

?

     while (copy_count < 5)
     {
       //
       HH_R[copy_count] = HR1_R;
       HH_G[copy_count] = HR1_G;
       HH_B[copy_count] = HR1_B;
       copy_count ++;
     }

A for loop would make more sense.

  //  Put on the 3, 6, 9, and 12 pointers  Not working.
//  /*
  X_R[THREE,0x55];
  X_G[THREE,0x55];      //  THREE
  X_B[THREE,0x55];
  
  X_R[SIX,0x55];
  X_G[SIX,0x55];        //  SIX
  X_B[SIX,0x55];
  
  X_R[NINE,0x55];
  X_G[NINE,0x55];        //  NINE
  X_B[NINE,0x55];
  
  X_R[TWELVE,0x55];
  X_G[TWELVE,0x55];        //  TWELVE
  X_B[TWELVE,0x55];

You are misusing the comma operator. You are not assigning anything to anything. This makes a much sense as

   47;

What, exactly, are you trying to assign the the X_R array?

Hi Paul.

The X_R/G/B arrays are the arrays which hold the value for the “numbers” around the ring/clock.

Earlier codes had MANY more and X was just a handy name at the time.

The values - of 0x55 - are just nominal values to give the LEDs so they glow.

Granted I missed the = in there to assign the values. Ooops.

That’s why I asked. :wink:

I am doing it in R G B so I can OR the values together when the “hands” overlap and still get a value which doesn’t remove the two hands and only leave one visible.

The <13 vs <=12… Well, true. But is any one better than the other?

while vs for:
Again, probably right.

I am going through a phase where I am using certain commands to help get my head around their useage.

This time is is while.

Appreciated.
Thanks.

But is any one better than the other?

That depends on your definition of better. Both produce the same result, but one makes it conceptually easier to understand the significance of the constant.

I am doing it in R G B so I can OR the values together

There is no ORing going on there.

The values - of 0x55 - are just nominal values to give the LEDs so they glow.

Perhaps you should visit Wikipedia, and search for comma operator, and read the article. Your code is not doing what you seem to think it is. Read about why your perception is incorrect.

Ok, my mistake on the explination.

The OR is done at another part of the code which "mixes" the two hands (positions) together.

Earlier codes just overwrote one "hand" with the other one and so it looked a bit yucky.

Shall go to wiki and read the article.

Thanks.