Using an RTC to turn a set of lights on a schedule.

Hello, I am new to the forum and new to arduino. I currently working a project that has me stumped. I am trying to build a clock for my classroom that will tell the time and activate a “traffic light” at the appropriate times during the day. For example:

  • Green light on at the start of class
  • Yellow light on at 10 minutes to the end of class
  • yellow and red at 5 minute to end of class warning
  • red light on a the end of class

I would also like to able to scroll messages across my clock at the 10 and 5 minute warning times.

I also need to the code to watch the days of the week because our school has a different bell schedule on monday then the other days.

With the help of a friend that helped me tweek the final code I have managed to program a clock with a 16X32 dot matrix from adafruit , an Arduino Uno R3, and I am using a D3231 RTC with the D3231.h library from rinkydinkelctronics.com. The clock part works great.

When I try to add the scrolling text, the scrolling text “stutters”.

I am not sure how to proceed to combine all the things I would like this code to do. Do I use Case/Switch or state machines or what? I have researching this for a while and I could use some advice on how to start. I don’t want to overcomplicate my code.

Any tips would be appreciated.

The following files are the clock code and the modified code that is glitchy.

Matrix_Clock.ino (2.52 KB)

Matrix_Clock_Scrolling.ino (4.3 KB)

Your CleanUp() routine is called only from setup but not in loop(). Why? Calling it only once won't show any scrolling.

I was testing the function before I went any further. It does scroll once then the time displays but it does not scroll as smoothly as it does when the code is seperate. I modified the code from Adafruit GFX examples 16x32 scrolling text.

Hi @schabanow,

Do not hijack other people’s threads.

Do not post code without code tags.

Read the forum guidelines in the sticky post.

Oh, my apologies! I supposed it was good not to start a new topic as I noticed a similar one in the list... Just a moment...

SilverTeacher:
I was testing the function before I went any further. It does scroll once then the time displays but it does not scroll as smoothly as it does when the code is seperate. I modified the code from Adafruit GFX examples 16x32 scrolling text.

But CleanUp() is meant to be called repeatedly otherwise it won't work. Did you try to call the function in every round of loop()?